2016-09-24 18:11:01 -04:00
|
|
|
var CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
var defaultsDeep = require('lodash.defaultsdeep');
|
2016-09-26 10:02:24 -04:00
|
|
|
var path = require('path');
|
2016-04-18 17:20:30 -04:00
|
|
|
var webpack = require('webpack');
|
|
|
|
|
2016-09-20 15:52:35 -04:00
|
|
|
var base = {
|
2016-09-26 10:02:24 -04:00
|
|
|
devServer: {
|
|
|
|
contentBase: path.resolve(__dirname, 'playground'),
|
2016-11-21 14:25:08 -05:00
|
|
|
host: '0.0.0.0',
|
|
|
|
port: process.env.PORT || 8073
|
2016-09-26 10:02:24 -04:00
|
|
|
},
|
2017-01-13 16:34:26 -05:00
|
|
|
devtool: 'source-map',
|
2016-04-26 09:49:52 -04:00
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
test: /\.json$/,
|
|
|
|
loader: 'json-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2016-04-18 17:20:30 -04:00
|
|
|
plugins: [
|
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
include: /\.min\.js$/,
|
2016-04-26 09:49:52 -04:00
|
|
|
minimize: true,
|
|
|
|
compress: {
|
|
|
|
warnings: false
|
|
|
|
}
|
2016-04-18 17:20:30 -04:00
|
|
|
})
|
|
|
|
]
|
|
|
|
};
|
2016-09-20 15:52:35 -04:00
|
|
|
|
2016-09-24 18:11:01 -04:00
|
|
|
module.exports = [
|
2017-01-13 16:34:26 -05:00
|
|
|
// Web-compatible
|
2016-09-24 18:11:01 -04:00
|
|
|
defaultsDeep({}, base, {
|
2017-01-13 16:34:26 -05:00
|
|
|
target: 'web',
|
2016-09-24 18:11:01 -04:00
|
|
|
entry: {
|
2017-01-13 16:34:26 -05:00
|
|
|
'scratch-vm': './src/index.js',
|
|
|
|
'scratch-vm.min': './src/index.js'
|
2016-09-24 18:11:01 -04:00
|
|
|
},
|
|
|
|
output: {
|
2017-01-13 16:34:26 -05:00
|
|
|
path: path.resolve(__dirname, 'dist/web'),
|
2016-09-24 18:11:01 -04:00
|
|
|
filename: '[name].js'
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
loaders: base.module.loaders.concat([
|
|
|
|
{
|
|
|
|
test: require.resolve('./src/index.js'),
|
|
|
|
loader: 'expose?VirtualMachine'
|
|
|
|
}
|
|
|
|
])
|
|
|
|
}
|
|
|
|
}),
|
2017-01-13 16:34:26 -05:00
|
|
|
// Node-compatible
|
2016-09-24 18:11:01 -04:00
|
|
|
defaultsDeep({}, base, {
|
2017-01-13 16:34:26 -05:00
|
|
|
target: 'node',
|
2016-09-24 18:11:01 -04:00
|
|
|
entry: {
|
2017-01-13 16:34:26 -05:00
|
|
|
'scratch-vm': './src/index.js'
|
2016-09-24 18:11:01 -04:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
library: 'VirtualMachine',
|
|
|
|
libraryTarget: 'commonjs2',
|
2017-01-13 16:34:26 -05:00
|
|
|
path: path.resolve(__dirname, 'dist/node'),
|
2016-09-24 18:11:01 -04:00
|
|
|
filename: '[name].js'
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
// Playground
|
|
|
|
defaultsDeep({}, base, {
|
2017-01-13 16:34:26 -05:00
|
|
|
target: 'web',
|
2016-09-24 18:11:01 -04:00
|
|
|
entry: {
|
2017-01-13 16:34:26 -05:00
|
|
|
'scratch-vm': './src/index.js',
|
|
|
|
'vendor': [
|
2016-09-24 18:11:01 -04:00
|
|
|
// FPS counter
|
|
|
|
'stats.js/build/stats.min.js',
|
|
|
|
// Syntax highlighter
|
|
|
|
'highlightjs/highlight.pack.min.js',
|
|
|
|
// Scratch Blocks
|
|
|
|
'scratch-blocks/dist/vertical.js',
|
|
|
|
// Renderer
|
2017-01-06 11:49:25 -05:00
|
|
|
'scratch-render',
|
|
|
|
// Audio
|
|
|
|
'scratch-audio'
|
2016-09-24 18:11:01 -04:00
|
|
|
]
|
|
|
|
},
|
|
|
|
output: {
|
2016-09-26 10:02:24 -04:00
|
|
|
path: path.resolve(__dirname, 'playground'),
|
2016-09-24 18:11:01 -04:00
|
|
|
filename: '[name].js'
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
loaders: base.module.loaders.concat([
|
|
|
|
{
|
|
|
|
test: require.resolve('./src/index.js'),
|
|
|
|
loader: 'expose?VirtualMachine'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: require.resolve('stats.js/build/stats.min.js'),
|
|
|
|
loader: 'script'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: require.resolve('highlightjs/highlight.pack.min.js'),
|
|
|
|
loader: 'script'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: require.resolve('scratch-blocks/dist/vertical.js'),
|
|
|
|
loader: 'expose?Blockly'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: require.resolve('scratch-render'),
|
|
|
|
loader: 'expose?RenderWebGL'
|
2017-01-06 11:49:25 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: require.resolve('scratch-audio'),
|
|
|
|
loader: 'expose?AudioEngine'
|
2016-09-24 18:11:01 -04:00
|
|
|
}
|
|
|
|
])
|
|
|
|
},
|
|
|
|
plugins: base.plugins.concat([
|
|
|
|
new CopyWebpackPlugin([{
|
|
|
|
from: 'node_modules/scratch-blocks/media',
|
2016-09-26 10:02:24 -04:00
|
|
|
to: 'media'
|
2016-09-24 18:11:01 -04:00
|
|
|
}, {
|
2016-09-26 10:02:24 -04:00
|
|
|
from: 'node_modules/highlightjs/styles/zenburn.css'
|
2016-09-24 18:11:01 -04:00
|
|
|
}])
|
|
|
|
])
|
|
|
|
})
|
|
|
|
];
|