scratch-render/webpack.config.js
Christopher Willis-Ford e958e4bfff Fix playground, plus misc. cleanup
The playground was trying to build with a now-missing entry point.
Also, I fixed some JSDoc comments, added HTML labels, etc. until IDEA
had no meaningful complaints about `playground/index.html`.
2018-01-10 17:42:38 -08:00

86 lines
2.2 KiB
JavaScript

const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const base = {
devServer: {
contentBase: false,
host: '0.0.0.0',
port: process.env.PORT || 8361
},
devtool: 'cheap-module-source-map',
module: {
rules: [
{
include: [
path.resolve('src')
],
test: /\.js$/,
loader: 'babel-loader',
options: {
presets: ['es2015']
}
},
{
test: /node_modules[\\/](linebreak|grapheme-breaker)[\\/].*\.js$/,
loader: 'ify-loader'
}
]
},
plugins: process.env.NODE_ENV === 'production' ? [
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true
})
] : []
};
module.exports = [
// Playground
Object.assign({}, base, {
target: 'web',
entry: {
'scratch-render': './src/index.js'
},
output: {
library: 'ScratchRender',
libraryTarget: 'umd',
path: path.resolve('playground'),
filename: '[name].js'
},
plugins: base.plugins.concat([
new CopyWebpackPlugin([
{
from: 'src/playground'
}
])
])
}),
// Web-compatible
Object.assign({}, base, {
target: 'web',
entry: {
'scratch-render': './src/index.js',
'scratch-render.min': './src/index.js'
},
output: {
library: 'ScratchRender',
libraryTarget: 'umd',
path: path.resolve('dist', 'web'),
filename: '[name].js'
}
}),
// Node-compatible
Object.assign({}, base, {
target: 'node',
entry: {
'scratch-render': './src/index.js'
},
output: {
library: 'ScratchRender',
libraryTarget: 'commonjs2',
path: path.resolve('dist', 'node'),
filename: '[name].js'
}
})
];