2018-02-13 22:10:32 +00:00
|
|
|
const path = require('path');
|
|
|
|
const webpack = require('webpack');
|
2018-02-10 21:05:25 +00:00
|
|
|
const merge = require('webpack-merge');
|
|
|
|
const common = require('./webpack.common.js');
|
|
|
|
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
|
2018-02-10 21:08:42 +00:00
|
|
|
const WorkboxPlugin = require('workbox-webpack-plugin');
|
2018-02-13 22:10:32 +00:00
|
|
|
const nodeExternals = require('webpack-node-externals');
|
2018-02-10 21:05:25 +00:00
|
|
|
|
2018-02-13 22:10:32 +00:00
|
|
|
module.exports = [
|
|
|
|
// Web
|
|
|
|
merge(common, {
|
2018-03-08 00:09:08 +00:00
|
|
|
mode: 'production',
|
2018-02-13 22:10:32 +00:00
|
|
|
devtool: 'source-map',
|
|
|
|
plugins: [
|
|
|
|
new UglifyJSPlugin({
|
|
|
|
sourceMap: true
|
|
|
|
}),
|
|
|
|
new WorkboxPlugin({
|
|
|
|
clientsClaim: true,
|
2018-02-24 21:43:08 +00:00
|
|
|
skipWaiting: true,
|
|
|
|
runtimeCaching: [
|
|
|
|
{
|
2018-02-25 22:33:55 +00:00
|
|
|
urlPattern: /https?:\/\/licensebuttons\.net/,
|
2018-02-24 21:43:08 +00:00
|
|
|
handler: 'staleWhileRevalidate'
|
|
|
|
},
|
|
|
|
{
|
2018-02-25 22:33:55 +00:00
|
|
|
urlPattern: /https?:\/\/fonts\.googleapis\.com/,
|
2018-02-24 21:43:08 +00:00
|
|
|
handler: 'staleWhileRevalidate'
|
|
|
|
},
|
|
|
|
{
|
2018-02-25 22:33:55 +00:00
|
|
|
urlPattern: /https?:\/\/fonts\.gstatic\.com/,
|
2018-02-24 21:43:08 +00:00
|
|
|
handler: 'staleWhileRevalidate'
|
|
|
|
}
|
|
|
|
]
|
2018-02-13 22:10:32 +00:00
|
|
|
})
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
// Node (prerender)
|
|
|
|
{
|
2018-03-08 00:09:08 +00:00
|
|
|
mode: 'production',
|
2018-02-13 22:10:32 +00:00
|
|
|
target: 'node',
|
|
|
|
externals: [nodeExternals({
|
|
|
|
whitelist: [ /\.svg$/ ]
|
|
|
|
})],
|
|
|
|
entry: {
|
2018-02-16 22:16:23 +00:00
|
|
|
prerender: './script/prerender.js'
|
2018-02-13 22:10:32 +00:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
filename: '[name].js',
|
|
|
|
chunkFilename: '[name].chunk.js',
|
2018-02-16 22:16:23 +00:00
|
|
|
path: path.resolve(__dirname, 'script/__build__')
|
2018-02-13 22:10:32 +00:00
|
|
|
},
|
2018-02-14 01:09:52 +00:00
|
|
|
resolve: {
|
|
|
|
modules: ['src', 'node_modules']
|
|
|
|
},
|
2018-02-13 22:10:32 +00:00
|
|
|
plugins: [
|
|
|
|
// Only want the EnvironmentPlugin
|
|
|
|
common.plugins.find(plugin => plugin instanceof webpack.EnvironmentPlugin)
|
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
// Replace the rule for CSS files
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
2018-02-13 23:15:18 +00:00
|
|
|
loader: 'css-loader/locals',
|
|
|
|
options: {
|
|
|
|
modules: true
|
|
|
|
}
|
2018-02-13 22:10:32 +00:00
|
|
|
},
|
2018-02-13 23:15:18 +00:00
|
|
|
...common.module.rules.filter(rule => !rule.test.test('file.css'))
|
2018-02-13 22:10:32 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|