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