2017-07-04 03:28:56 +00:00
|
|
|
'use strict';
|
|
|
|
process.env.NODE_ENV = 'production';
|
2017-04-12 04:59:58 +00:00
|
|
|
|
2017-07-04 03:28:56 +00:00
|
|
|
const webpack = require('webpack');
|
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
|
|
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
|
2017-04-12 04:59:58 +00:00
|
|
|
// const OfflinePlugin = require('offline-plugin')
|
2017-07-04 03:28:56 +00:00
|
|
|
const base = require('./webpack.base');
|
|
|
|
const config = require('./config');
|
2017-07-17 15:35:25 +00:00
|
|
|
const rimraf = require('rimraf');
|
2017-06-13 00:20:52 +00:00
|
|
|
const distFolder = 'dist/';
|
2017-04-12 04:59:58 +00:00
|
|
|
|
2017-07-17 15:35:25 +00:00
|
|
|
// Clear out build folder
|
2017-09-13 17:56:20 +00:00
|
|
|
rimraf.sync(distFolder, { rmdirSync: true });
|
2017-04-12 04:59:58 +00:00
|
|
|
|
2017-09-13 17:56:20 +00:00
|
|
|
base.devtool = 'source-map';
|
2017-04-12 04:59:58 +00:00
|
|
|
base.module.loaders.push(
|
2017-07-04 03:28:56 +00:00
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: ExtractTextPlugin.extract({
|
|
|
|
fallback: 'style-loader',
|
|
|
|
use: 'css-loader'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: ExtractTextPlugin.extract({
|
|
|
|
fallback: 'style-loader',
|
|
|
|
use: ['css-loader', 'sass-loader']
|
|
|
|
})
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
use: ExtractTextPlugin.extract({
|
|
|
|
fallback: 'style-loader',
|
|
|
|
use: ['css-loader', 'less-loader']
|
|
|
|
})
|
|
|
|
}
|
|
|
|
);
|
2017-04-12 04:59:58 +00:00
|
|
|
// a white list to add dependencies to vendor chunk
|
2017-07-04 03:28:56 +00:00
|
|
|
base.entry.vendor = config.vendor;
|
2017-04-12 04:59:58 +00:00
|
|
|
// use hash filename to support long-term caching
|
2017-07-04 03:28:56 +00:00
|
|
|
base.output.filename = '[name].[chunkhash:8].js';
|
2017-04-12 04:59:58 +00:00
|
|
|
// add webpack plugins
|
|
|
|
base.plugins.push(
|
2017-07-04 03:28:56 +00:00
|
|
|
new ProgressPlugin(),
|
|
|
|
new ExtractTextPlugin('[name].[chunkhash:8].css'),
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NODE_ENV': JSON.stringify('production')
|
|
|
|
}),
|
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
sourceMap: true,
|
|
|
|
compress: {
|
|
|
|
warnings: false
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
comments: false
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
// extract vendor chunks
|
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
|
|
name: 'vendor',
|
|
|
|
filename: 'vendor.[chunkhash:8].js'
|
|
|
|
})
|
|
|
|
// For progressive web apps
|
|
|
|
// new OfflinePlugin({
|
|
|
|
// relativePaths: false,
|
|
|
|
// AppCache: false,
|
|
|
|
// ServiceWorker: {
|
|
|
|
// events: true
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
);
|
2017-04-12 04:59:58 +00:00
|
|
|
|
|
|
|
// minimize webpack output
|
|
|
|
base.stats = {
|
2017-07-04 03:28:56 +00:00
|
|
|
// Add children information
|
|
|
|
children: false,
|
|
|
|
// Add chunk information (setting this to `false` allows for a less verbose output)
|
|
|
|
chunks: false,
|
|
|
|
// Add built modules information to chunk information
|
|
|
|
chunkModules: false,
|
|
|
|
chunkOrigins: false,
|
|
|
|
modules: false
|
|
|
|
};
|
2017-04-12 04:59:58 +00:00
|
|
|
|
2017-07-04 03:28:56 +00:00
|
|
|
module.exports = base;
|