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:
Ray Schamp 2016-09-20 09:11:56 -04:00
parent fb3f677e2c
commit 278cddf04e
3 changed files with 33 additions and 17 deletions

View file

@ -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'
}
})];