2017-04-20 19:17:05 -04:00
|
|
|
const path = require('path');
|
2024-03-08 22:51:36 -05:00
|
|
|
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
2024-03-04 17:21:57 -05:00
|
|
|
const webpack = require('webpack');
|
2016-04-18 17:20:30 -04:00
|
|
|
|
2024-03-08 22:51:36 -05:00
|
|
|
const ScratchWebpackConfigBuilder = require('scratch-webpack-configuration');
|
|
|
|
|
|
|
|
const common = {
|
|
|
|
libraryName: 'scratch-vm',
|
|
|
|
rootPath: path.resolve(__dirname)
|
2016-04-18 17:20:30 -04:00
|
|
|
};
|
2016-09-20 15:52:35 -04:00
|
|
|
|
2024-03-08 23:10:00 -05:00
|
|
|
const nodeBuilder = new ScratchWebpackConfigBuilder(common)
|
2024-03-08 22:51:36 -05:00
|
|
|
.setTarget('node')
|
|
|
|
.addModuleRule({
|
|
|
|
test: /\.mp3$/,
|
|
|
|
type: 'asset'
|
2024-03-08 23:10:00 -05:00
|
|
|
});
|
2024-03-08 22:51:36 -05:00
|
|
|
|
2024-03-08 23:10:00 -05:00
|
|
|
const webBuilder = new ScratchWebpackConfigBuilder(common)
|
2024-03-08 22:51:36 -05:00
|
|
|
.setTarget('browserslist')
|
|
|
|
.merge({
|
|
|
|
resolve: {
|
|
|
|
fallback: {
|
|
|
|
Buffer: require.resolve('buffer/')
|
|
|
|
}
|
2016-09-24 18:11:01 -04:00
|
|
|
}
|
2024-03-08 22:51:36 -05:00
|
|
|
})
|
|
|
|
.addModuleRule({
|
|
|
|
test: /\.mp3$/,
|
|
|
|
type: 'asset'
|
|
|
|
})
|
|
|
|
.addModuleRule({
|
|
|
|
test: require.resolve('./src/index.js'),
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: 'VirtualMachine'
|
2018-02-14 17:55:11 -05:00
|
|
|
}
|
2024-03-08 22:51:36 -05:00
|
|
|
})
|
|
|
|
.addPlugin(new webpack.ProvidePlugin({
|
|
|
|
Buffer: ['buffer', 'Buffer']
|
2024-03-08 23:10:00 -05:00
|
|
|
}));
|
2024-03-08 22:51:36 -05:00
|
|
|
|
2024-03-08 23:10:00 -05:00
|
|
|
const playgroundBuilder = webBuilder.clone()
|
2024-03-08 22:51:36 -05:00
|
|
|
.merge({
|
2024-02-28 14:26:05 -05:00
|
|
|
devServer: {
|
|
|
|
contentBase: false,
|
|
|
|
host: '0.0.0.0',
|
|
|
|
port: process.env.PORT || 8073
|
|
|
|
},
|
2024-03-08 22:51:36 -05:00
|
|
|
performance: {
|
|
|
|
hints: false
|
|
|
|
},
|
2016-09-24 18:11:01 -04:00
|
|
|
entry: {
|
2019-01-22 17:42:34 -05:00
|
|
|
'benchmark': './src/playground/benchmark',
|
2018-03-30 14:54:58 -04:00
|
|
|
'video-sensing-extension-debug': './src/extensions/scratch3_video_sensing/debug'
|
2016-09-24 18:11:01 -04:00
|
|
|
},
|
|
|
|
output: {
|
2024-03-08 22:51:36 -05:00
|
|
|
path: path.resolve(__dirname, 'playground')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.addModuleRule({
|
2024-03-08 23:10:00 -05:00
|
|
|
test: require.resolve('stats.js/build/stats.min.js'),
|
|
|
|
loader: 'script-loader'
|
2024-03-08 22:51:36 -05:00
|
|
|
})
|
|
|
|
.addModuleRule({
|
|
|
|
test: require.resolve('./src/extensions/scratch3_video_sensing/debug.js'),
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: 'Scratch3VideoSensingDebug'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.addModuleRule({
|
|
|
|
test: require.resolve('scratch-blocks/dist/vertical.js'),
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: 'Blockly'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.addModuleRule({
|
|
|
|
test: require.resolve('scratch-audio/src/index.js'),
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: 'AudioEngine'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.addModuleRule({
|
|
|
|
test: require.resolve('scratch-storage/src/index.js'),
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: 'ScratchStorage'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.addModuleRule({
|
|
|
|
test: require.resolve('scratch-render/src/index.js'),
|
|
|
|
loader: 'expose-loader',
|
|
|
|
options: {
|
|
|
|
exposes: 'ScratchRender'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.addPlugin(new CopyWebpackPlugin([
|
|
|
|
{
|
|
|
|
from: 'node_modules/scratch-blocks/media',
|
|
|
|
to: 'media'
|
2017-11-09 18:35:12 -05:00
|
|
|
},
|
2024-03-08 22:51:36 -05:00
|
|
|
{
|
|
|
|
from: 'node_modules/scratch-storage/dist/web'
|
2018-05-03 18:56:10 -04:00
|
|
|
},
|
2024-03-08 22:51:36 -05:00
|
|
|
{
|
|
|
|
from: 'node_modules/scratch-render/dist/web'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'node_modules/scratch-svg-renderer/dist/web'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
from: 'src/playground'
|
|
|
|
}
|
2024-03-08 23:10:00 -05:00
|
|
|
]));
|
2024-03-08 22:51:36 -05:00
|
|
|
|
|
|
|
module.exports = [
|
2024-03-08 23:10:00 -05:00
|
|
|
nodeBuilder.get(),
|
|
|
|
webBuilder.get(),
|
|
|
|
playgroundBuilder.get()
|
2016-09-24 18:11:01 -04:00
|
|
|
];
|