mirror of
https://github.com/scratchfoundation/scratch-webpack-configuration.git
synced 2024-11-28 10:36:25 -05:00
feat: add chunk splitting
This commit is contained in:
parent
d4c2daa77a
commit
c1046e9a91
1 changed files with 9 additions and 1 deletions
|
@ -3,6 +3,8 @@ const path = require('path');
|
||||||
const merge = require('lodash.merge');
|
const merge = require('lodash.merge');
|
||||||
const nodeExternals = require('webpack-node-externals');
|
const nodeExternals = require('webpack-node-externals');
|
||||||
|
|
||||||
|
const DEFAULT_CHUNK_FILENAME = 'chunks/[name].[chunkhash].js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('webpack').Configuration} Configuration
|
* @typedef {import('webpack').Configuration} Configuration
|
||||||
* @typedef {import('webpack').RuleSetRule} RuleSetRule
|
* @typedef {import('webpack').RuleSetRule} RuleSetRule
|
||||||
|
@ -51,11 +53,17 @@ class ScratchWebpackConfigBuilder {
|
||||||
[libraryName]: path.resolve(this._srcPath, 'index')
|
[libraryName]: path.resolve(this._srcPath, 'index')
|
||||||
} : path.resolve(this._srcPath, 'index'),
|
} : path.resolve(this._srcPath, 'index'),
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: isProduction
|
minimize: isProduction,
|
||||||
|
splitChunks: {
|
||||||
|
chunks: 'all',
|
||||||
|
filename: DEFAULT_CHUNK_FILENAME
|
||||||
|
},
|
||||||
|
mergeDuplicateChunks: true
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
clean: true,
|
clean: true,
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
|
chunkFilename: DEFAULT_CHUNK_FILENAME,
|
||||||
path: this._distPath,
|
path: this._distPath,
|
||||||
library: {
|
library: {
|
||||||
name: libraryName,
|
name: libraryName,
|
||||||
|
|
Loading…
Reference in a new issue