scratch-render/webpack.config.js

90 lines
2.3 KiB
JavaScript
Raw Normal View History

const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const base = {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
devServer: {
contentBase: false,
host: '0.0.0.0',
2017-03-08 16:16:20 -08:00
port: process.env.PORT || 8361
},
devtool: 'cheap-module-source-map',
module: {
2017-02-02 10:28:11 -08:00
rules: [
2016-06-15 14:39:44 -07:00
{
include: [
path.resolve('src')
],
2016-06-15 14:39:44 -07:00
test: /\.js$/,
loader: 'babel-loader',
2017-02-02 10:28:11 -08:00
options: {
presets: [['env', {targets: {browsers: ['last 3 versions', 'Safari >= 8', 'iOS >= 8']}}]]
2016-06-15 14:39:44 -07:00
}
},
{
test: /node_modules[\\/](linebreak|grapheme-breaker)[\\/].*\.js$/,
loader: 'ify-loader'
}
]
},
optimization: {
minimizer: [
new UglifyJsPlugin({
include: /\.min\.js$/
})
]
},
plugins: []
};
2016-09-23 19:43:56 -04:00
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'
}
])
])
}),
2016-09-23 19:43:56 -04:00
// Web-compatible
Object.assign({}, base, {
target: 'web',
2016-09-23 19:43:56 -04:00
entry: {
'scratch-render': './src/index.js',
'scratch-render.min': './src/index.js'
2016-09-23 19:43:56 -04:00
},
output: {
library: 'ScratchRender',
libraryTarget: 'umd',
path: path.resolve('dist', 'web'),
2016-09-23 19:43:56 -04:00
filename: '[name].js'
2016-09-27 09:42:04 -04:00
}
2016-09-23 19:43:56 -04:00
}),
// Node-compatible
2016-09-23 19:43:56 -04:00
Object.assign({}, base, {
target: 'node',
2016-09-23 19:43:56 -04:00
entry: {
'scratch-render': './src/index.js'
2016-09-23 19:43:56 -04:00
},
output: {
library: 'ScratchRender',
libraryTarget: 'commonjs2',
path: path.resolve('dist', 'node'),
filename: '[name].js'
2016-09-23 19:43:56 -04:00
}
})
];