scratch-vm/webpack.config.js

148 lines
3.6 KiB
JavaScript
Raw Normal View History

const path = require('path');
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
const ScratchWebpackConfigBuilder = require('scratch-webpack-configuration');
const common = {
libraryName: 'scratch-vm',
rootPath: path.resolve(__dirname)
2016-04-18 17:20:30 -04:00
};
const nodeConfig = new ScratchWebpackConfigBuilder(common)
.setTarget('node')
.addModuleRule({
test: /\.mp3$/,
type: 'asset'
})
.get();
const webConfig = new ScratchWebpackConfigBuilder(common)
.setTarget('browserslist')
.merge({
resolve: {
fallback: {
Buffer: require.resolve('buffer/')
}
}
})
.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
}
})
.addPlugin(new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
}))
.get();
const playgroundConfig = new ScratchWebpackConfigBuilder(common)
.setTarget('browserslist')
.merge({
devServer: {
contentBase: false,
host: '0.0.0.0',
port: process.env.PORT || 8073
},
performance: {
hints: false
},
entry: {
2019-01-22 17:42:34 -05:00
'benchmark': './src/playground/benchmark',
'video-sensing-extension-debug': './src/extensions/scratch3_video_sensing/debug'
},
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'
}
})
.addModuleRule({
test: require.resolve('./src/extensions/scratch3_video_sensing/debug.js'),
loader: 'expose-loader',
options: {
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',
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 webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
}))
.addPlugin(new CopyWebpackPlugin([
{
from: 'node_modules/scratch-blocks/media',
to: 'media'
},
{
from: 'node_modules/scratch-storage/dist/web'
2018-05-03 18:56:10 -04:00
},
{
from: 'node_modules/scratch-render/dist/web'
},
{
from: 'node_modules/scratch-svg-renderer/dist/web'
},
{
from: 'src/playground'
}
]))
.get();
module.exports = [
nodeConfig,
webConfig,
playgroundConfig
];