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