2016-10-21 18:27:47 -07:00
|
|
|
const path = require('path');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
|
|
|
|
const base = {
|
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
include: [
|
|
|
|
path.resolve(__dirname, 'src')
|
|
|
|
],
|
|
|
|
test: /\.js$/,
|
|
|
|
loader: 'babel-loader',
|
|
|
|
query: {
|
|
|
|
presets: ['es2015']
|
|
|
|
}
|
2016-12-08 16:38:38 -08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.json$/,
|
|
|
|
loader: 'json-loader'
|
2016-10-21 18:27:47 -07:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
include: /\.min\.js$/,
|
|
|
|
minimize: true,
|
|
|
|
compress: {
|
|
|
|
warnings: false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = [
|
|
|
|
// Web-compatible
|
|
|
|
Object.assign({}, base, {
|
2016-12-06 16:23:11 -08:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2016-12-06 16:23:11 -08:00
|
|
|
// Node-compatible
|
2016-10-21 18:27:47 -07:00
|
|
|
Object.assign({}, base, {
|
2016-12-06 16:23:11 -08:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
];
|