mirror of
https://github.com/scratchfoundation/scratch-storage.git
synced 2025-08-05 02:49:53 -04:00
Using UMD makes the build output more flexible and adds a very small amount of overhead. The "browser" field is one of the key features we've been missing and should solve many of our build frustrations. See here for details on the "browser" field in `project.json`: https://github.com/defunctzombie/package-browser-field-spec
58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
const path = require('path');
|
|
const webpack = require('webpack');
|
|
|
|
const base = {
|
|
devtool: 'cheap-module-source-map',
|
|
module: {
|
|
rules: [
|
|
{
|
|
include: [
|
|
path.resolve('src')
|
|
],
|
|
test: /\.js$/,
|
|
loader: 'babel-loader',
|
|
options: {
|
|
presets: ['es2015']
|
|
}
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
include: /\.min\.js$/,
|
|
minimize: true,
|
|
sourceMap: true
|
|
})
|
|
]
|
|
};
|
|
|
|
module.exports = [
|
|
// Web-compatible
|
|
Object.assign({}, base, {
|
|
target: 'web',
|
|
entry: {
|
|
'scratch-storage': './src/index-web.js',
|
|
'scratch-storage.min': './src/index-web.js'
|
|
},
|
|
output: {
|
|
library: 'ScratchStorage',
|
|
libraryTarget: 'umd',
|
|
path: path.resolve('dist', 'web'),
|
|
filename: '[name].js'
|
|
}
|
|
}),
|
|
|
|
// Node-compatible
|
|
Object.assign({}, base, {
|
|
target: 'node',
|
|
entry: {
|
|
'scratch-storage': './src/index.js'
|
|
},
|
|
output: {
|
|
library: 'ScratchStorage',
|
|
libraryTarget: 'commonjs2',
|
|
path: path.resolve('dist', 'node'),
|
|
filename: '[name].js'
|
|
}
|
|
})
|
|
];
|