scratch-vm/webpack.config.js

118 lines
3.2 KiB
JavaScript
Raw Normal View History

var CopyWebpackPlugin = require('copy-webpack-plugin');
var defaultsDeep = require('lodash.defaultsdeep');
var path = require('path');
2016-04-18 17:20:30 -04:00
var webpack = require('webpack');
var base = {
devServer: {
contentBase: path.resolve(__dirname, 'playground'),
host: '0.0.0.0'
},
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader'
}
]
},
2016-04-18 17:20:30 -04:00
plugins: [
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true,
compress: {
warnings: false
}
2016-04-18 17:20:30 -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
output: {
library: 'VirtualMachine',
libraryTarget: 'commonjs2',
path: __dirname,
filename: '[name].js'
}
}),
// Playground
defaultsDeep({}, base, {
entry: {
'vm': './src/index.js',
'vendor': [
// 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: {
path: path.resolve(__dirname, 'playground'),
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',
to: 'media'
}, {
from: 'node_modules/highlightjs/styles/zenburn.css'
2016-10-12 20:58:03 -04:00
}, {
from: 'assets'
}])
])
})
];