2018-01-26 05:32:53 +00:00
|
|
|
const webpack = require('webpack')
|
|
|
|
const merge = require('webpack-merge')
|
2018-02-03 21:48:25 +00:00
|
|
|
const path = require('path')
|
2018-01-26 05:32:53 +00:00
|
|
|
|
|
|
|
const CleanWebpackPlugin = require('clean-webpack-plugin')
|
|
|
|
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
|
2018-01-27 01:22:31 +00:00
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
2018-01-28 03:06:18 +00:00
|
|
|
const OfflinePlugin = require('offline-plugin')
|
2018-01-28 02:40:51 +00:00
|
|
|
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin')
|
2018-02-03 21:48:25 +00:00
|
|
|
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin')
|
2018-01-26 05:32:53 +00:00
|
|
|
|
|
|
|
const common = require('./webpack.common.js')
|
|
|
|
|
|
|
|
module.exports = merge(common, {
|
|
|
|
module: {
|
|
|
|
rules: []
|
|
|
|
},
|
|
|
|
plugins: [
|
2018-02-03 21:48:25 +00:00
|
|
|
new SimpleProgressWebpackPlugin({
|
|
|
|
format: 'expanded'
|
|
|
|
}),
|
2018-01-30 03:58:05 +00:00
|
|
|
new CleanWebpackPlugin([
|
|
|
|
'assets/js/*.*',
|
|
|
|
'assets/css/*.*',
|
|
|
|
'assets/*.js',
|
|
|
|
'assets/*.json'
|
|
|
|
], {
|
|
|
|
root: process.cwd(),
|
|
|
|
verbose: false
|
|
|
|
}),
|
2018-02-03 21:48:25 +00:00
|
|
|
new UglifyJSPlugin({
|
|
|
|
cache: path.join(process.cwd(), '.webpack-cache/uglify'),
|
|
|
|
parallel: true
|
|
|
|
}),
|
2018-01-26 05:32:53 +00:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NODE_ENV': JSON.stringify('production')
|
2018-01-27 01:22:31 +00:00
|
|
|
}),
|
2018-01-28 02:40:51 +00:00
|
|
|
new ExtractTextPlugin('css/bundle.css'),
|
2018-01-28 03:06:18 +00:00
|
|
|
new OfflinePlugin({
|
2018-02-03 21:48:25 +00:00
|
|
|
publicPath: '/',
|
|
|
|
externals: ['/'],
|
2018-01-28 03:06:18 +00:00
|
|
|
caches: {
|
|
|
|
main: [
|
|
|
|
'js/runtime.js',
|
|
|
|
'js/vendor.js',
|
|
|
|
'js/client.js'
|
|
|
|
],
|
2018-02-03 21:48:25 +00:00
|
|
|
additional: [
|
|
|
|
':externals:'
|
|
|
|
],
|
|
|
|
optional: [
|
|
|
|
'js/*.chunk.js'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
safeToUseOptionalCaches: true
|
2018-01-28 03:06:18 +00:00
|
|
|
}),
|
2018-02-03 21:48:25 +00:00
|
|
|
new DuplicatePackageCheckerPlugin(),
|
|
|
|
// Disable Extract Text Plugin stats:
|
|
|
|
{
|
|
|
|
apply(compiler) {
|
|
|
|
compiler.plugin('done', stats => {
|
|
|
|
if (Array.isArray(stats.compilation.children)) {
|
|
|
|
stats.compilation.children = stats.compilation.children.filter(child => {
|
|
|
|
return child.name.indexOf('extract-text-webpack-plugin') !== 0
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2018-01-26 05:32:53 +00:00
|
|
|
]
|
|
|
|
})
|