mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-09 14:32:07 -05:00
fix(build): simplify webpack config using clone()
This commit is contained in:
parent
9261909f90
commit
e7962b101d
3 changed files with 16 additions and 39 deletions
8
package-lock.json
generated
8
package-lock.json
generated
|
@ -58,7 +58,7 @@
|
||||||
"scratch-l10n": "3.18.53",
|
"scratch-l10n": "3.18.53",
|
||||||
"scratch-render-fonts": "1.0.20",
|
"scratch-render-fonts": "1.0.20",
|
||||||
"scratch-semantic-release-config": "1.0.14",
|
"scratch-semantic-release-config": "1.0.14",
|
||||||
"scratch-webpack-configuration": "1.0.0",
|
"scratch-webpack-configuration": "1.1.0",
|
||||||
"script-loader": "0.7.2",
|
"script-loader": "0.7.2",
|
||||||
"semantic-release": "19.0.5",
|
"semantic-release": "19.0.5",
|
||||||
"stats.js": "0.17.0",
|
"stats.js": "0.17.0",
|
||||||
|
@ -18704,9 +18704,9 @@
|
||||||
"integrity": "sha512-lC0ohKbx1g+q5fvYUmG0sFxEdlWL7BUcUxkah5UzUAFE5eqhW+JS7U9bFm4HbwqSovuuI1Xpl4qyu/9yJtrW5w=="
|
"integrity": "sha512-lC0ohKbx1g+q5fvYUmG0sFxEdlWL7BUcUxkah5UzUAFE5eqhW+JS7U9bFm4HbwqSovuuI1Xpl4qyu/9yJtrW5w=="
|
||||||
},
|
},
|
||||||
"node_modules/scratch-webpack-configuration": {
|
"node_modules/scratch-webpack-configuration": {
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/scratch-webpack-configuration/-/scratch-webpack-configuration-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/scratch-webpack-configuration/-/scratch-webpack-configuration-1.1.0.tgz",
|
||||||
"integrity": "sha512-8t3Lda+kOPR/C+0jR1eOmyLO4pjDjT0BAWtmrZ1sXYfCmDhZreOwZMD6127aFYZbCWGK3qn0j2fjSi+unBnG4g==",
|
"integrity": "sha512-YjdOWGphdgOa/0HA3D6f2+WVLd0rj5UuwqowyLMZsXDGeoqlOHz2RVObWCkZ+/HBcQxsyy7gMjPX3dV6Mj+rbQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash.merge": "^4.6.2",
|
"lodash.merge": "^4.6.2",
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
"scratch-l10n": "3.18.53",
|
"scratch-l10n": "3.18.53",
|
||||||
"scratch-render-fonts": "1.0.20",
|
"scratch-render-fonts": "1.0.20",
|
||||||
"scratch-semantic-release-config": "1.0.14",
|
"scratch-semantic-release-config": "1.0.14",
|
||||||
"scratch-webpack-configuration": "1.0.0",
|
"scratch-webpack-configuration": "1.1.0",
|
||||||
"script-loader": "0.7.2",
|
"script-loader": "0.7.2",
|
||||||
"semantic-release": "19.0.5",
|
"semantic-release": "19.0.5",
|
||||||
"stats.js": "0.17.0",
|
"stats.js": "0.17.0",
|
||||||
|
|
|
@ -10,15 +10,14 @@ const common = {
|
||||||
rootPath: path.resolve(__dirname)
|
rootPath: path.resolve(__dirname)
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeConfig = new ScratchWebpackConfigBuilder(common)
|
const nodeBuilder = new ScratchWebpackConfigBuilder(common)
|
||||||
.setTarget('node')
|
.setTarget('node')
|
||||||
.addModuleRule({
|
.addModuleRule({
|
||||||
test: /\.mp3$/,
|
test: /\.mp3$/,
|
||||||
type: 'asset'
|
type: 'asset'
|
||||||
})
|
});
|
||||||
.get();
|
|
||||||
|
|
||||||
const webConfig = new ScratchWebpackConfigBuilder(common)
|
const webBuilder = new ScratchWebpackConfigBuilder(common)
|
||||||
.setTarget('browserslist')
|
.setTarget('browserslist')
|
||||||
.merge({
|
.merge({
|
||||||
resolve: {
|
resolve: {
|
||||||
|
@ -40,11 +39,9 @@ const webConfig = new ScratchWebpackConfigBuilder(common)
|
||||||
})
|
})
|
||||||
.addPlugin(new webpack.ProvidePlugin({
|
.addPlugin(new webpack.ProvidePlugin({
|
||||||
Buffer: ['buffer', 'Buffer']
|
Buffer: ['buffer', 'Buffer']
|
||||||
}))
|
}));
|
||||||
.get();
|
|
||||||
|
|
||||||
const playgroundConfig = new ScratchWebpackConfigBuilder(common)
|
const playgroundBuilder = webBuilder.clone()
|
||||||
.setTarget('browserslist')
|
|
||||||
.merge({
|
.merge({
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: false,
|
contentBase: false,
|
||||||
|
@ -60,23 +57,11 @@ const playgroundConfig = new ScratchWebpackConfigBuilder(common)
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'playground')
|
path: path.resolve(__dirname, 'playground')
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
fallback: {
|
|
||||||
Buffer: require.resolve('buffer/')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addModuleRule({
|
.addModuleRule({
|
||||||
test: /\.mp3$/,
|
test: require.resolve('stats.js/build/stats.min.js'),
|
||||||
type: 'asset'
|
loader: 'script-loader'
|
||||||
})
|
|
||||||
.addModuleRule({
|
|
||||||
test: require.resolve('./src/index.js'),
|
|
||||||
loader: 'expose-loader',
|
|
||||||
options: {
|
|
||||||
exposes: 'VirtualMachine'
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.addModuleRule({
|
.addModuleRule({
|
||||||
test: require.resolve('./src/extensions/scratch3_video_sensing/debug.js'),
|
test: require.resolve('./src/extensions/scratch3_video_sensing/debug.js'),
|
||||||
|
@ -85,10 +70,6 @@ const playgroundConfig = new ScratchWebpackConfigBuilder(common)
|
||||||
exposes: 'Scratch3VideoSensingDebug'
|
exposes: 'Scratch3VideoSensingDebug'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addModuleRule({
|
|
||||||
test: require.resolve('stats.js/build/stats.min.js'),
|
|
||||||
loader: 'script-loader'
|
|
||||||
})
|
|
||||||
.addModuleRule({
|
.addModuleRule({
|
||||||
test: require.resolve('scratch-blocks/dist/vertical.js'),
|
test: require.resolve('scratch-blocks/dist/vertical.js'),
|
||||||
loader: 'expose-loader',
|
loader: 'expose-loader',
|
||||||
|
@ -117,9 +98,6 @@ const playgroundConfig = new ScratchWebpackConfigBuilder(common)
|
||||||
exposes: 'ScratchRender'
|
exposes: 'ScratchRender'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addPlugin(new webpack.ProvidePlugin({
|
|
||||||
Buffer: ['buffer', 'Buffer']
|
|
||||||
}))
|
|
||||||
.addPlugin(new CopyWebpackPlugin([
|
.addPlugin(new CopyWebpackPlugin([
|
||||||
{
|
{
|
||||||
from: 'node_modules/scratch-blocks/media',
|
from: 'node_modules/scratch-blocks/media',
|
||||||
|
@ -137,11 +115,10 @@ const playgroundConfig = new ScratchWebpackConfigBuilder(common)
|
||||||
{
|
{
|
||||||
from: 'src/playground'
|
from: 'src/playground'
|
||||||
}
|
}
|
||||||
]))
|
]));
|
||||||
.get();
|
|
||||||
|
|
||||||
module.exports = [
|
module.exports = [
|
||||||
nodeConfig,
|
nodeBuilder.get(),
|
||||||
webConfig,
|
webBuilder.get(),
|
||||||
playgroundConfig
|
playgroundBuilder.get()
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue