|
@@ -1,16 +1,22 @@
|
|
|
var path = require('path')
|
|
|
-var config = require('../config')
|
|
|
var utils = require('./utils')
|
|
|
var webpack = require('webpack')
|
|
|
+var config = require('../config')
|
|
|
var merge = require('webpack-merge')
|
|
|
var baseWebpackConfig = require('./webpack.base.conf')
|
|
|
-var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
|
|
+var CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
|
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
|
+var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
|
|
+var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
|
|
|
+
|
|
|
var env = config.build.env
|
|
|
|
|
|
var webpackConfig = merge(baseWebpackConfig, {
|
|
|
module: {
|
|
|
- loaders: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true })
|
|
|
+ rules: utils.styleLoaders({
|
|
|
+ sourceMap: config.build.productionSourceMap,
|
|
|
+ extract: true
|
|
|
+ })
|
|
|
},
|
|
|
devtool: config.build.productionSourceMap ? '#source-map' : false,
|
|
|
output: {
|
|
@@ -18,19 +24,7 @@ var webpackConfig = merge(baseWebpackConfig, {
|
|
|
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
|
|
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
|
|
|
},
|
|
|
- vue: {
|
|
|
- loaders: utils.cssLoaders({
|
|
|
- sourceMap: config.build.productionSourceMap,
|
|
|
- extract: true
|
|
|
- })
|
|
|
- },
|
|
|
plugins: [
|
|
|
- new webpack.ProvidePlugin({
|
|
|
- $: 'jquery',
|
|
|
- jquery: 'jquery',
|
|
|
- 'window.jQuery': 'jquery',
|
|
|
- jQuery: 'jquery'
|
|
|
- }),
|
|
|
// http://vuejs.github.io/vue-loader/en/workflow/production.html
|
|
|
new webpack.DefinePlugin({
|
|
|
'process.env': env
|
|
@@ -38,11 +32,16 @@ var webpackConfig = merge(baseWebpackConfig, {
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
compress: {
|
|
|
warnings: false
|
|
|
- }
|
|
|
+ },
|
|
|
+ sourceMap: true
|
|
|
}),
|
|
|
- new webpack.optimize.OccurrenceOrderPlugin(),
|
|
|
// extract css into its own file
|
|
|
- new ExtractTextPlugin(utils.assetsPath('css/[name].[contenthash].css')),
|
|
|
+ new ExtractTextPlugin({
|
|
|
+ filename: utils.assetsPath('css/[name].[contenthash].css')
|
|
|
+ }),
|
|
|
+ // Compress extracted CSS. We are using this plugin so that possible
|
|
|
+ // duplicated CSS from different components can be deduped.
|
|
|
+ new OptimizeCSSPlugin(),
|
|
|
// generate dist index.html with correct asset hash for caching.
|
|
|
// you can customize output by editing /index.html
|
|
|
// see https://github.com/ampedandwired/html-webpack-plugin
|
|
@@ -79,7 +78,15 @@ var webpackConfig = merge(baseWebpackConfig, {
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
|
name: 'manifest',
|
|
|
chunks: ['vendor']
|
|
|
- })
|
|
|
+ }),
|
|
|
+ // copy custom static assets
|
|
|
+ new CopyWebpackPlugin([
|
|
|
+ {
|
|
|
+ from: path.resolve(__dirname, '../static'),
|
|
|
+ to: config.build.assetsSubDirectory,
|
|
|
+ ignore: ['.*']
|
|
|
+ }
|
|
|
+ ])
|
|
|
]
|
|
|
})
|
|
|
|
|
@@ -101,4 +108,9 @@ if (config.build.productionGzip) {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+if (config.build.bundleAnalyzerReport) {
|
|
|
+ var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
|
|
+ webpackConfig.plugins.push(new BundleAnalyzerPlugin())
|
|
|
+}
|
|
|
+
|
|
|
module.exports = webpackConfig
|