diff options
author | Yukai Huang | 2016-10-19 22:41:20 +0800 |
---|---|---|
committer | Yukai Huang | 2016-11-02 08:36:18 +0800 |
commit | 03772fe887716dad19b61d91e0e57f4f3c5afe91 (patch) | |
tree | 02f46ed5bc8e7a734f90ba8df42fb9cb56249aec | |
parent | e42770904267707f01a73c766b2a5c2682a2c059 (diff) |
Refactor webpack production config
-rw-r--r-- | webpack.production.js | 74 |
1 files changed, 3 insertions, 71 deletions
diff --git a/webpack.production.js b/webpack.production.js index 82e52d17..5fe6f294 100644 --- a/webpack.production.js +++ b/webpack.production.js @@ -1,77 +1,9 @@ var baseConfig = require('./webpackBaseConfig'); var webpack = require('webpack'); -var ExtractTextPlugin = require("extract-text-webpack-plugin"); var path = require('path'); -var HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = Object.assign({}, baseConfig, { - plugins: [ - new webpack.ProvidePlugin({ - Visibility: "visibilityjs", - Cookies: "js-cookie", - key: "keymaster", - $: "jquery", - jQuery: "jquery", - "window.jQuery": "jquery", - "moment": "moment", - "Handlebars": "handlebars" - }), - new ExtractTextPlugin("[name].css"), - new webpack.optimize.CommonsChunkPlugin({ - names: ["cover", "index", "pretty", "slide", "vendor"], - children: true, - async: true, - filename: '[name].js', - minChunks: Infinity - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/header.ejs', - chunks: ['vendor', 'index'], - filename: path.join(__dirname, 'public/views/build/index-header.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/scripts.ejs', - chunks: ['vendor', 'index'], - filename: path.join(__dirname, 'public/views/build/index-scripts.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/header.ejs', - chunks: ['vendor', 'cover'], - filename: path.join(__dirname, 'public/views/build/cover-header.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/scripts.ejs', - chunks: ['vendor', 'cover'], - filename: path.join(__dirname, 'public/views/build/cover-scripts.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/header.ejs', - chunks: ['vendor', 'pretty'], - filename: path.join(__dirname, 'public/views/build/pretty-header.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/scripts.ejs', - chunks: ['vendor', 'pretty'], - filename: path.join(__dirname, 'public/views/build/pretty-scripts.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/header.ejs', - chunks: ['vendor', 'slide'], - filename: path.join(__dirname, 'public/views/build/slide-header.ejs'), - inject: false - }), - new HtmlWebpackPlugin({ - template: 'public/views/includes/scripts.ejs', - chunks: ['vendor', 'slide'], - filename: path.join(__dirname, 'public/views/build/slide-scripts.ejs'), - inject: false - }), + plugins: baseConfig.plugins.concat([ new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('production') @@ -84,11 +16,11 @@ module.exports = Object.assign({}, baseConfig, { mangle: false, sourceMap: false }) - ], + ]), output: { path: path.join(__dirname, 'public/build'), publicPath: '/build/', filename: '[id].[name].[hash].js' - }, + } }); |