2018-07-16 13:57:56 -04:00
|
|
|
const webpack = require('webpack');
|
2017-11-13 01:23:39 -05:00
|
|
|
const merge = require('webpack-merge');
|
|
|
|
const common = require('./webpack.web.common.js');
|
|
|
|
|
|
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
2019-06-19 20:57:14 -04:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2017-11-13 01:23:39 -05:00
|
|
|
const ManifestPlugin = require('webpack-manifest-plugin');
|
2019-06-19 20:57:14 -04:00
|
|
|
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
|
2017-11-13 01:23:39 -05:00
|
|
|
|
2019-06-19 20:57:14 -04:00
|
|
|
const Terser = require('terser');
|
2017-11-13 01:23:39 -05:00
|
|
|
|
2018-07-16 13:57:56 -04:00
|
|
|
// Get Git info
|
|
|
|
|
|
|
|
const commit_hash = require('child_process').execSync('git rev-parse HEAD').toString().trim();
|
|
|
|
|
2018-03-15 16:59:10 -04:00
|
|
|
/* global module Buffer */
|
|
|
|
|
2019-06-19 20:57:14 -04:00
|
|
|
module.exports = merge(common, {
|
|
|
|
mode: 'production',
|
2017-11-13 01:23:39 -05:00
|
|
|
devtool: 'source-map',
|
|
|
|
|
2019-06-19 20:57:14 -04:00
|
|
|
optimization: {
|
|
|
|
concatenateModules: false,
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
sourceMap: true,
|
|
|
|
terserOptions: {
|
2017-11-13 01:23:39 -05:00
|
|
|
keep_classnames: true,
|
|
|
|
keep_fnames: true
|
|
|
|
}
|
2019-06-19 20:57:14 -04:00
|
|
|
})
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
new CleanWebpackPlugin(),
|
2018-07-16 13:57:56 -04:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
__git_commit__: JSON.stringify(commit_hash)
|
|
|
|
}),
|
2017-11-13 01:23:39 -05:00
|
|
|
new CopyPlugin([
|
|
|
|
{
|
|
|
|
from: './src/entry.js',
|
|
|
|
to: 'script.min.js',
|
2018-03-15 16:59:10 -04:00
|
|
|
transform: content => {
|
2017-11-13 01:23:39 -05:00
|
|
|
const text = content.toString('utf8');
|
2019-06-19 20:57:14 -04:00
|
|
|
const minified = Terser.minify(text);
|
2017-11-13 01:23:39 -05:00
|
|
|
return (minified && minified.code) ? Buffer.from(minified.code) : content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]),
|
|
|
|
new ManifestPlugin({
|
2019-06-20 15:30:18 -04:00
|
|
|
publicPath: '',
|
2018-03-15 16:59:10 -04:00
|
|
|
map: data => {
|
2017-11-13 01:23:39 -05:00
|
|
|
if ( data.name.endsWith('.scss') )
|
2018-03-15 16:59:10 -04:00
|
|
|
data.name = `${data.name.substr(0,data.name.length - 5)}.css`;
|
2017-11-13 01:23:39 -05:00
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
|
|
|
|
output: {
|
2018-03-30 23:34:56 -04:00
|
|
|
publicPath: '//cdn.frankerfacez.com/static/',
|
2017-11-13 01:23:39 -05:00
|
|
|
filename: '[name].[hash].js'
|
|
|
|
}
|
2019-06-19 20:57:14 -04:00
|
|
|
});
|