123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- const webpack = require('webpack');
- const merge = require('webpack-merge');
- const path = require('path');
- const base = require('./webpack.base.config');
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const ExtractTextPlugin = require("extract-text-webpack-plugin");
- const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
- // const BabelMinifyPlugin = require("babel-minify-webpack-plugin");
- let output = {
- path : path.resolve(__dirname, `./build`),
- publicPath : `build/`,
- filename : 'bundle/[name].bundle.js?[hash]',
- chunkFilename : 'chunk/[name].chunk.js?[hash]'
- }
- // config.output.path = config.extraPath + '/build';
- // config.output.publicPath = 'build/';
- // config.output.filename = '[name].js?[hash]';
- // config.output.chunkFilename = '[name].chunk.js?[hash]';
- // config.vue = {
- // loaders : {
- // css: ExtractTextPlugin.extract(
- // "style-loader",
- // "css-loader?sourceMap",
- // {
- // publicPath: './',
- // }
- // ),
- // less: ExtractTextPlugin.extract(
- // 'vue-style-loader',
- // 'css-loader!less-loader'
- // ),
- // sass: ExtractTextPlugin.extract(
- // 'vue-style-loader',
- // 'css-loader!sass-loader',
- // {
- // publicPath: './',
- // }
- // )
- // }
- // }
- // config.plugins = (config.plugins || []).concat([
- // new ExtractTextPlugin("[name].css?[hash]",{ allChunks : false, resolve : ['modules'] }),
- // new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js?[hash]'),
- // new webpack.DefinePlugin({
- // 'process.env': {
- // NODE_ENV: '"production"'
- // }
- // }),
- // new webpack.optimize.UglifyJsPlugin({
- // compress: {
- // warnings: false
- // }
- // }),
- // new HtmlWebpackPlugin({
- // filename: '../index.html',
- // template: './index.ejs',
- // inject: false
- // }),
- // new webpack.ProvidePlugin({
- // $: "jquery",
- // jQuery: "jquery",
- // "window.jQuery": "jquery"
- // })
- // ]);
- let plugins = [
- new ExtractTextPlugin("style/[name].css?[hash]",{
- allChunks : true,
- resolve : ['modules']
- }),
- new webpack.optimize.CommonsChunkPlugin({
- name : 'vendors',
- filename : 'chunk/vendors.chunk.js?[hash]'
- }),
- new webpack.DefinePlugin({
- 'process.env': {
- NODE_ENV: JSON.stringify("production")
- }
- }),
- new UglifyJSPlugin({
- uglifyOptions: {
- compress: {
- warnings: false
- }
- },
- parallel: true
- }),
- // new BabelMinifyPlugin(),
- new HtmlWebpackPlugin({
- filename: './index.html',
- template: './index.ejs',
- inject: 'body',
- // chunks: ['main','vendors'],
- minify: {
- html5: false,
- removeComments: true,
- removeEmptyAttributes: true,
- collapseWhitespace: true
- }
- }),
- new webpack.ProvidePlugin({
- $: "jquery",
- jQuery: "jquery",
- "window.jQuery": "jquery"
- })
- ]
- module.exports = merge(base, {
- // devtool: 'source-map',
- output: output,
- plugins: plugins
- });
|