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:
@@ -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'
|
||||
}
|
||||
})];
|
||||
|
||||
Reference in New Issue
Block a user