scratch-vm/webpack.config.js

143 lines
3.6 KiB
JavaScript
Raw Normal View History

const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
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 nodeBuilder = new ScratchWebpackConfigBuilder(common)
.setTarget('node')
.merge({
entry: {
'extension-worker': path.join(__dirname, 'src/extension-support/extension-worker.js')
},
output: {
library: {
name: 'VirtualMachine'
}
}
})
.addModuleRule({
test: /\.mp3$/,
type: 'asset'
});
const webBuilder = new ScratchWebpackConfigBuilder(common)
.setTarget('browserslist')
.merge({
entry: {
'extension-worker': path.join(__dirname, 'src/extension-support/extension-worker.js')
},
resolve: {
fallback: {
Buffer: require.resolve('buffer/')
}
},
output: {
library: {
name: 'VirtualMachine'
}
}
})
.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
}
});
const playgroundBuilder = webBuilder.clone()
.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',
'extension-worker': path.join(__dirname, 'src/extension-support/extension-worker.js')
},
output: {
path: path.resolve(__dirname, 'playground'),
library: {
name: 'VirtualMachine'
}
}
})
.addModuleRule({
test: require.resolve('stats.js/build/stats.min.js'),
loader: 'script-loader'
})
.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'),
loader: 'expose-loader',
options: {
exposes: 'ScratchRender'
}
})
.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'
}
]));
module.exports = [
nodeBuilder.get(),
webBuilder.get(),
playgroundBuilder.get()
];