mirror of
https://github.com/scratchfoundation/scratch-render.git
synced 2025-08-14 15:29:17 -04:00
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`.
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
var path = require('path');
|
|
var webpack = require('webpack');
|
|
|
|
var base = {
|
|
module: {
|
|
loaders: [
|
|
{
|
|
include: [
|
|
path.resolve(__dirname, 'src')
|
|
],
|
|
test: /\.js$/,
|
|
loader: 'babel-loader',
|
|
query: {
|
|
presets: ['es2015']
|
|
}
|
|
},
|
|
{
|
|
test: /\.json$/,
|
|
loader: 'json-loader'
|
|
},
|
|
{
|
|
test: /\.(glsl|vs|fs|frag|vert)$/,
|
|
loader: 'raw-loader'
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
include: /\.min\.js$/,
|
|
minimize: true,
|
|
compress: {
|
|
warnings: false
|
|
}
|
|
})
|
|
]
|
|
};
|
|
|
|
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'
|
|
}
|
|
})];
|