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'),
|
|
|
|
host: '0.0.0.0'
|
|
|
|
},
|
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 = [
|
|
|
|
// Web-compatible, playground
|
|
|
|
defaultsDeep({}, base, {
|
|
|
|
entry: {
|
|
|
|
'vm': './src/index.js',
|
|
|
|
'vm.min': './src/index.js'
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: __dirname,
|
|
|
|
filename: '[name].js'
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
loaders: base.module.loaders.concat([
|
|
|
|
{
|
|
|
|
test: require.resolve('./src/index.js'),
|
|
|
|
loader: 'expose?VirtualMachine'
|
|
|
|
}
|
|
|
|
])
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
// Webpack-compatible
|
|
|
|
defaultsDeep({}, base, {
|
|
|
|
entry: {
|
|
|
|
'dist': './src/index.js'
|
|
|
|
},
|
2016-10-12 20:58:03 -04:00
|
|
|
|
2016-09-24 18:11:01 -04:00
|
|
|
output: {
|
|
|
|
library: 'VirtualMachine',
|
|
|
|
libraryTarget: 'commonjs2',
|
|
|
|
path: __dirname,
|
|
|
|
filename: '[name].js'
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
// Playground
|
|
|
|
defaultsDeep({}, base, {
|
|
|
|
entry: {
|
2016-09-26 10:02:24 -04:00
|
|
|
'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
|
|
|
|
'scratch-render'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
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'
|
|
|
|
}
|
|
|
|
])
|
|
|
|
},
|
|
|
|
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-10-12 20:58:03 -04:00
|
|
|
}, {
|
|
|
|
from: 'assets'
|
2016-09-24 18:11:01 -04:00
|
|
|
}])
|
|
|
|
])
|
|
|
|
})
|
|
|
|
];
|