mirror of
https://github.com/scratchfoundation/scratch-storage.git
synced 2025-08-13 06:51:17 -04:00
Use UMD for browser output; add "browser" field
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
This commit is contained in:
parent
d05faba7fd
commit
07841c0496
4 changed files with 13 additions and 25 deletions
|
@ -7,7 +7,7 @@ const base = {
|
|||
rules: [
|
||||
{
|
||||
include: [
|
||||
path.resolve(__dirname, 'src')
|
||||
path.resolve('src')
|
||||
],
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
|
@ -27,34 +27,22 @@ const base = {
|
|||
};
|
||||
|
||||
module.exports = [
|
||||
// Web + UMD
|
||||
// Web-compatible
|
||||
Object.assign({}, base, {
|
||||
target: 'web',
|
||||
entry: {
|
||||
'scratch-storage': './src/index-web.js',
|
||||
'scratch-storage.min': './src/index-web.js'
|
||||
},
|
||||
output: {
|
||||
path: __dirname,
|
||||
filename: 'dist/web_umd/[name].js'
|
||||
}
|
||||
}),
|
||||
|
||||
// Web + commonjs2
|
||||
Object.assign({}, base, {
|
||||
target: 'web',
|
||||
entry: {
|
||||
'scratch-storage': './src/index.js'
|
||||
},
|
||||
output: {
|
||||
library: 'ScratchStorage',
|
||||
libraryTarget: 'commonjs2',
|
||||
path: __dirname,
|
||||
filename: 'dist/web_commonjs2/[name].js'
|
||||
libraryTarget: 'umd',
|
||||
path: path.resolve('dist', 'web'),
|
||||
filename: '[name].js'
|
||||
}
|
||||
}),
|
||||
|
||||
// Node + commonjs2
|
||||
// Node-compatible
|
||||
Object.assign({}, base, {
|
||||
target: 'node',
|
||||
entry: {
|
||||
|
@ -63,8 +51,8 @@ module.exports = [
|
|||
output: {
|
||||
library: 'ScratchStorage',
|
||||
libraryTarget: 'commonjs2',
|
||||
path: __dirname,
|
||||
filename: 'dist/node_commonjs2/[name].js'
|
||||
path: path.resolve('dist', 'node'),
|
||||
filename: '[name].js'
|
||||
}
|
||||
})
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue