mirror of
https://github.com/scratchfoundation/scratch-render.git
synced 2025-08-28 22:30:04 -04:00
Build module to be imported
If another package wants to import `src/index.js`, it needs to replicate the loader config in `webpack.config.js`. To avoid this, package the module in `dist.js` and set that as the module to require. I changed `main` to point to this so that other packages can just `require('scratch-blocks')`, but it would also work for our purposes to add `"webpack": "./dist.js"` if we want to keep `src/index.js` as `main`.
This commit is contained in:
parent
fb3f677e2c
commit
278cddf04e
3 changed files with 33 additions and 17 deletions
|
@ -1,15 +1,7 @@
|
|||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
'render': './src/index-web.js',
|
||||
'render.min': './src/index-web.js'
|
||||
},
|
||||
output: {
|
||||
path: __dirname,
|
||||
filename: '[name].js'
|
||||
},
|
||||
var base = {
|
||||
module: {
|
||||
loaders: [
|
||||
{
|
||||
|
@ -42,3 +34,25 @@ module.exports = {
|
|||
})
|
||||
]
|
||||
};
|
||||
|
||||
module.exports = [Object.assign({}, base, {
|
||||
entry: {
|
||||
'render': './src/index-web.js',
|
||||
'render.min': './src/index-web.js'
|
||||
},
|
||||
output: {
|
||||
path: __dirname,
|
||||
filename: '[name].js'
|
||||
},
|
||||
}),
|
||||
Object.assign({}, base, {
|
||||
entry: {
|
||||
'render': './src/index.js'
|
||||
},
|
||||
output: {
|
||||
library: 'ScratchRender',
|
||||
libraryTarget: 'commonjs2',
|
||||
path: __dirname,
|
||||
filename: 'dist.js'
|
||||
}
|
||||
})];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue