regexper-static/webpack.prod.js

75 lines
1.8 KiB
JavaScript
Raw Normal View History

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');
const nodeExternals = require('webpack-node-externals');
2018-02-10 21:05:25 +00:00
module.exports = [
// Web
merge(common, {
mode: 'production',
devtool: 'source-map',
plugins: [
new UglifyJSPlugin({
sourceMap: true
}),
new WorkboxPlugin({
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [
{
2018-02-25 22:33:55 +00:00
urlPattern: /https?:\/\/licensebuttons\.net/,
handler: 'staleWhileRevalidate'
},
{
2018-02-25 22:33:55 +00:00
urlPattern: /https?:\/\/fonts\.googleapis\.com/,
handler: 'staleWhileRevalidate'
},
{
2018-02-25 22:33:55 +00:00
urlPattern: /https?:\/\/fonts\.gstatic\.com/,
handler: 'staleWhileRevalidate'
}
]
})
]
}),
// Node (prerender)
{
mode: 'production',
target: 'node',
externals: [nodeExternals({
whitelist: [ /\.svg$/ ]
})],
entry: {
prerender: './script/prerender.js'
},
output: {
filename: '[name].js',
chunkFilename: '[name].chunk.js',
path: path.resolve(__dirname, 'script/__build__')
},
2018-02-14 01:09:52 +00:00
resolve: {
modules: ['src', 'node_modules']
},
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 23:15:18 +00:00
...common.module.rules.filter(rule => !rule.test.test('file.css'))
]
}
}
];