scratch-render/webpack.config.js
Christopher Willis-Ford 47b46fb1aa Update Webpack config like scratch-storage
- Move build outputs into `dist/`
- Make build output file names more consistent
- Update `playground/index.html` for new output file name
- Explicitly specify target => Node output is much smaller
- Minor fixes / cleanup in `.gitignore` and `src/index*.js`
2016-12-12 12:06:05 -08:00

76 lines
1.8 KiB
JavaScript

const path = require('path');
const webpack = require('webpack');
const base = {
devServer: {
contentBase: path.resolve(__dirname, 'playground'),
host: '0.0.0.0',
watchOptions: {
aggregateTimeout: 300,
poll: 1000
},
stats: {
colors: true
}
},
module: {
loaders: [
{
include: [
path.resolve(__dirname, 'src')
],
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.(glsl|vs|fs|frag|vert)$/,
loader: 'raw-loader'
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true,
compress: {
warnings: false
}
})
]
};
module.exports = [
// Web-compatible
Object.assign({}, base, {
target: 'web',
entry: {
'dist/web/scratch-render': './src/index-web.js',
'dist/web/scratch-render.min': './src/index-web.js',
'playground/scratch-render': './src/index-web.js'
},
output: {
path: __dirname,
filename: '[name].js'
}
}),
// Webpack-compatible
Object.assign({}, base, {
target: 'node',
entry: {
'scratch-render': './src/index.js'
},
output: {
library: 'ScratchRender',
libraryTarget: 'commonjs2',
path: __dirname,
filename: 'dist/node/[name].js'
}
})
];