scratch-svg-renderer/webpack.config.js

53 lines
1.6 KiB
JavaScript
Raw Normal View History

const defaultsdeep = require('lodash.defaultsdeep');
2017-09-05 11:57:48 -04:00
const path = require('path');
const webpack = require('webpack');
2018-04-25 16:08:35 -04:00
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
2017-09-05 11:57:48 -04:00
const makeExport = function (targets, settings) {
const base = {
2018-04-25 16:08:35 -04:00
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
devtool: 'cheap-module-source-map',
module: {
rules: [{
include: path.resolve('src'),
test: /\.js$/,
loader: 'babel-loader',
options: {
presets: [['env', {targets}]]
}
}]
},
entry: {
'scratch-svg-renderer': './src/index.js'
},
2018-04-25 16:08:35 -04:00
optimization: {
minimize: process.env.NODE_ENV === 'production' && /dist[\//]web/.test(settings.output.path)
}
};
return defaultsdeep(base, settings);
2017-09-05 11:57:48 -04:00
};
module.exports = [
makeExport({browsers: ['last 3 versions', 'Safari >= 8', 'iOS >= 8']}, {
output: {
library: 'ScratchSVGRenderer',
libraryTarget: 'umd',
path: path.resolve('dist', 'web'),
filename: '[name].js'
}
}),
// For testing only: many features will fail outside a browser
makeExport({node: true, uglify: true}, {
output: {
library: 'ScratchSVGRenderer',
libraryTarget: 'commonjs2',
path: path.resolve('dist', 'node'),
filename: '[name].js'
2018-04-25 16:08:35 -04:00
},
performance: {
hints: false
}
})
];