forked from external-repos/squoosh
Lint webpack config, and only preload initial chunks
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
const CleanPlugin = require('clean-webpack-plugin');
|
||||||
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||||
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
||||||
@@ -14,11 +14,11 @@ const CrittersPlugin = require('./config/critters-webpack-plugin');
|
|||||||
const WatchTimestampsPlugin = require('./config/watch-timestamps-plugin');
|
const WatchTimestampsPlugin = require('./config/watch-timestamps-plugin');
|
||||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||||
|
|
||||||
function readJson(filename) {
|
function readJson (filename) {
|
||||||
return JSON.parse(fs.readFileSync(filename));
|
return JSON.parse(fs.readFileSync(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function(_, env) {
|
module.exports = function (_, env) {
|
||||||
const isProd = env.mode === 'production';
|
const isProd = env.mode === 'production';
|
||||||
const nodeModules = path.join(__dirname, 'node_modules');
|
const nodeModules = path.join(__dirname, 'node_modules');
|
||||||
const componentStyleDirs = [
|
const componentStyleDirs = [
|
||||||
@@ -129,9 +129,10 @@ module.exports = function(_, env) {
|
|||||||
// Remove old files before outputting a production build:
|
// Remove old files before outputting a production build:
|
||||||
isProd && new CleanPlugin([
|
isProd && new CleanPlugin([
|
||||||
'assets',
|
'assets',
|
||||||
'**/*.{css,js,json,html}'
|
'**/*.{css,js,json,html,map}'
|
||||||
], {
|
], {
|
||||||
root: path.join(__dirname, 'build'),
|
root: path.join(__dirname, 'build'),
|
||||||
|
verbose: false,
|
||||||
beforeEmit: true
|
beforeEmit: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -181,7 +182,9 @@ module.exports = function(_, env) {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
// Inject <link rel="preload"> for resources
|
// Inject <link rel="preload"> for resources
|
||||||
isProd && new PreloadWebpackPlugin(),
|
isProd && new PreloadPlugin({
|
||||||
|
include: 'initial'
|
||||||
|
}),
|
||||||
|
|
||||||
isProd && new CrittersPlugin({
|
isProd && new CrittersPlugin({
|
||||||
// Don't inline fonts into critical CSS, but do preload them:
|
// Don't inline fonts into critical CSS, but do preload them:
|
||||||
|
|||||||
Reference in New Issue
Block a user