scratch-storage/webpack.config.js

57 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-10-21 18:27:47 -07:00
const path = require('path');
const webpack = require('webpack');
const base = {
devtool: 'cheap-module-source-map',
2016-10-21 18:27:47 -07:00
module: {
2017-02-03 12:18:05 -08:00
rules: [
2016-10-21 18:27:47 -07:00
{
include: [
path.resolve(__dirname, 'src')
],
test: /\.js$/,
loader: 'babel-loader',
2017-02-03 12:18:05 -08:00
options: {
2016-10-21 18:27:47 -07:00
presets: ['es2015']
}
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true,
2017-02-03 12:18:05 -08:00
sourceMap: true
2016-10-21 18:27:47 -07:00
})
]
};
module.exports = [
// Web-compatible
Object.assign({}, base, {
target: 'web',
2016-10-21 18:27:47 -07:00
entry: {
'scratch-storage': './src/index-web.js',
'scratch-storage.min': './src/index-web.js'
},
output: {
path: __dirname,
filename: 'dist/web/[name].js'
}
}),
// Node-compatible
2016-10-21 18:27:47 -07:00
Object.assign({}, base, {
target: 'node',
2016-10-21 18:27:47 -07:00
entry: {
'scratch-storage': './src/index.js'
},
output: {
library: 'ScratchStorage',
libraryTarget: 'commonjs2',
path: __dirname,
filename: 'dist/node/[name].js'
}
})
];