mirror of
https://github.com/scratchfoundation/scratch-storage.git
synced 2025-06-27 23:20:23 -04:00
Changes include: - Use `bin-loader` instead of `arraybuffer-loader` since the latter is only compatible with browsers, not with Node itself. - Use `got` instead of `xhr` since `xhr` only works in browsers and `got` is nicer anyway. - Add `json-loader` to Webpack config since `got` requires it. - Use lower-case values in `DataFormat` to match canonical file names. - Update `ScratchStorage.addWebSource` to match `WebHelper`'s new API. - Fix an error in the web helper which was causing an infinite loop on error.
61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
const path = require('path');
|
|
const webpack = require('webpack');
|
|
|
|
const base = {
|
|
module: {
|
|
loaders: [
|
|
{
|
|
include: [
|
|
path.resolve(__dirname, 'src')
|
|
],
|
|
test: /\.js$/,
|
|
loader: 'babel-loader',
|
|
query: {
|
|
presets: ['es2015']
|
|
}
|
|
},
|
|
{
|
|
test: /\.json$/,
|
|
loader: 'json-loader'
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
include: /\.min\.js$/,
|
|
minimize: true,
|
|
compress: {
|
|
warnings: false
|
|
}
|
|
})
|
|
]
|
|
};
|
|
|
|
module.exports = [
|
|
// 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/[name].js'
|
|
}
|
|
}),
|
|
|
|
// Node-compatible
|
|
Object.assign({}, base, {
|
|
target: 'node',
|
|
entry: {
|
|
'scratch-storage': './src/index.js'
|
|
},
|
|
output: {
|
|
library: 'ScratchStorage',
|
|
libraryTarget: 'commonjs2',
|
|
path: __dirname,
|
|
filename: 'dist/node/[name].js'
|
|
}
|
|
})
|
|
];
|