mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-16 10:39:53 +00:00
Update webpack configuration for Webpack 4
This commit is contained in:
committed by
Ingvar Stepanyan
parent
cf1a718534
commit
796324ad71
@@ -18,7 +18,8 @@ const addCssTypes = require('./config/add-css-types');
|
|||||||
|
|
||||||
const VERSION = require('./package.json').version;
|
const VERSION = require('./package.json').version;
|
||||||
|
|
||||||
module.exports = async function (_, env) {
|
/** @returns {Promise<import('webpack').Configuration>} */
|
||||||
|
module.exports = async 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 = [
|
||||||
@@ -57,14 +58,13 @@ module.exports = async function (_, env) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
// Disable the default JavaScript handling:
|
|
||||||
defaultRules: [],
|
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
oneOf: [
|
oneOf: [
|
||||||
{
|
{
|
||||||
test: /(\.mjs|\.esm\.js)$/i,
|
test: /(\.mjs|\.esm\.js)$/i,
|
||||||
type: 'javascript/esm',
|
// don't use strict esm resolution for mjs:
|
||||||
|
type: 'javascript/auto',
|
||||||
resolve: {},
|
resolve: {},
|
||||||
parser: {
|
parser: {
|
||||||
harmony: true,
|
harmony: true,
|
||||||
@@ -183,6 +183,7 @@ module.exports = async function (_, env) {
|
|||||||
format: '\u001b[90m\u001b[44mBuild\u001b[49m\u001b[39m [:bar] \u001b[32m\u001b[1m:percent\u001b[22m\u001b[39m (:elapseds) \u001b[2m:msg\u001b[22m\r',
|
format: '\u001b[90m\u001b[44mBuild\u001b[49m\u001b[39m [:bar] \u001b[32m\u001b[1m:percent\u001b[22m\u001b[39m (:elapseds) \u001b[2m:msg\u001b[22m\r',
|
||||||
renderThrottle: 100,
|
renderThrottle: 100,
|
||||||
summary: false,
|
summary: false,
|
||||||
|
total: 10,
|
||||||
clear: true
|
clear: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -198,10 +199,6 @@ module.exports = async function (_, env) {
|
|||||||
|
|
||||||
new WorkerPlugin(),
|
new WorkerPlugin(),
|
||||||
|
|
||||||
// Automatically split code into async chunks.
|
|
||||||
// See: https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
|
||||||
isProd && new webpack.optimize.SplitChunksPlugin({}),
|
|
||||||
|
|
||||||
// In production, extract all CSS to produce files on disk, even for
|
// In production, extract all CSS to produce files on disk, even for
|
||||||
// lazy-loaded CSS chunks. CSS for async chunks is loaded on-demand.
|
// lazy-loaded CSS chunks. CSS for async chunks is loaded on-demand.
|
||||||
// This is a modern Webpack 4 replacement for ExtractTextPlugin.
|
// This is a modern Webpack 4 replacement for ExtractTextPlugin.
|
||||||
@@ -302,6 +299,10 @@ module.exports = async function (_, env) {
|
|||||||
].filter(Boolean), // Filter out any falsey plugin array entries.
|
].filter(Boolean), // Filter out any falsey plugin array entries.
|
||||||
|
|
||||||
optimization: {
|
optimization: {
|
||||||
|
splitChunks: {
|
||||||
|
// Automatically split code into async chunks.
|
||||||
|
// See: https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
||||||
|
},
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
sourceMap: isProd,
|
sourceMap: isProd,
|
||||||
|
|||||||
Reference in New Issue
Block a user