Unverified Commit 82d843e9 authored by Dorian Johnson's avatar Dorian Johnson Committed by GitHub

build: use static CSS and JS filenames in dev (#534)

In production, it's helpful to use content addressing to guarantee cache busting
when publishing changes.

However, in development, because the server serves a static copy of the
index.html, that means that changing the Javascript bundle or CSS requires an
otherwise-unnecessary restart of the server.

This change makes the CSS and JS assets use fixed filenames so that a server
restart isn't needed.

Downside of this approach is there's now a dev/prod disparity and the config is
more spread out between files. The positive is we don't need to modify the
semantics of the server at all.
parent 4c5859a5
......@@ -100,11 +100,7 @@ const config: webpack.Configuration = {
plugins: [
new CleanWebpackPlugin(),
new MomentLocalesPlugin(), // To strip all locales except “en”
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css',
}),
...htmlWebpackPluginConfig,
// new BundleAnalyzerPlugin(), // Uncomment to analyze the production bundle on local
],
optimization: {
moduleIds: 'hashed',
......
import merge from 'webpack-merge';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
// import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import commonConfig from './webpack.common';
......@@ -7,6 +8,12 @@ export default merge(commonConfig, {
mode: 'development',
devtool: 'inline-source-map',
plugins: [
new MiniCssExtractPlugin({
filename: '[name].dev.css',
}),
// new BundleAnalyzerPlugin() // Uncomment to check the bundle size on dev
],
output: {
filename: '[name].dev.js',
},
});
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import merge from 'webpack-merge';
import TerserPlugin from 'terser-webpack-plugin';
import commonConfig from './webpack.common';
......@@ -14,4 +15,9 @@ export default merge(commonConfig, {
}),
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css',
}),
],
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment