2017-07-04 03:28:56 +00:00
|
|
|
'use strict';
|
|
|
|
process.env.NODE_ENV = 'production';
|
2017-12-30 20:29:04 +00:00
|
|
|
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
|
|
|
|
const path = require('path');
|
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-10-09 01:31:26 +00:00
|
|
|
const BabelMinifyPlugin = require('babel-minify-webpack-plugin');
|
2018-01-01 23:15:13 +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-12-30 20:29:04 +00:00
|
|
|
base.devtool = false;
|
|
|
|
base.module.rules.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
|
2017-12-30 20:29:04 +00:00
|
|
|
base.plugins.unshift(
|
|
|
|
new FaviconsWebpackPlugin({
|
|
|
|
logo: path.resolve(__dirname, '../static/favicon/android-chrome-384x384.png'),
|
|
|
|
background: '#163151',
|
|
|
|
inject: true
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2017-04-12 04:59:58 +00:00
|
|
|
base.plugins.push(
|
2017-07-04 03:28:56 +00:00
|
|
|
new ProgressPlugin(),
|
|
|
|
new ExtractTextPlugin('[name].[chunkhash:8].css'),
|
|
|
|
new webpack.DefinePlugin({
|
2017-12-30 20:29:04 +00:00
|
|
|
'process.env.BUILD_DOWNLOADABLE': JSON.stringify(!!process.env.BUILD_DOWNLOADABLE)
|
2017-07-04 03:28:56 +00:00
|
|
|
}),
|
2017-12-30 20:29:04 +00:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NODE_ENV': JSON.stringify('production')
|
2017-07-04 03:28:56 +00:00
|
|
|
}),
|
2018-01-02 00:12:27 +00:00
|
|
|
new BabelMinifyPlugin({
|
|
|
|
mangle: false
|
|
|
|
}, {
|
|
|
|
comments: false
|
|
|
|
}),
|
2017-07-04 03:28:56 +00:00
|
|
|
// extract vendor chunks
|
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
|
|
name: 'vendor',
|
|
|
|
filename: 'vendor.[chunkhash:8].js'
|
2018-01-01 23:15:13 +00:00
|
|
|
}),
|
|
|
|
new OfflinePlugin({
|
|
|
|
appShell: '/'
|
2017-07-04 03:28:56 +00:00
|
|
|
})
|
|
|
|
);
|
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;
|