subspace/webpack.common.js

108 lines
1.9 KiB
JavaScript
Raw Permalink Normal View History

const path = require("path");
const AddModuleExportsPlugin = require('add-module-exports-webpack-plugin');
const externals = {
react: {
commonjs: "react",
commonjs2: "react",
amd: "React",
root: "React"
},
"react-dom": {
commonjs: "react-dom",
commonjs2: "react-dom",
amd: "ReactDOM",
root: "ReactDOM"
},
electron: "electron",
"web3-eth": "web3-eth" // TODO: comment to pack web3-eth
};
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin;
2019-08-23 18:31:50 +00:00
const web = {
target: "web",
entry: path.join(__dirname, "src/index.js"),
module: {
rules: [
{
test: /\.js/,
exclude: /(node_modules)/,
use: [
{
loader: "babel-loader"
}
]
}
]
},
externals,
output: {
path: path.resolve(__dirname, "dist"),
filename: "browser.js",
library: "subspace",
libraryTarget: "umd"
},
node: {
fs: "empty"
2019-08-23 18:31:50 +00:00
},
optimization: {
usedExports: true,
sideEffects: true
},
plugins: [
// new BundleAnalyzerPlugin()
]
};
const react = {
...web,
entry: path.join(__dirname, "src/react/index.js"),
output: {
path: path.resolve(__dirname, "react"),
filename: "index.js",
library: "subspace-react",
libraryTarget: "umd"
},
plugins: []
};
2019-08-23 18:31:50 +00:00
const node = {
target: "node",
externals,
entry: path.join(__dirname, "src/index.js"),
module: {
rules: [
{
test: /\.js/,
exclude: /(node_modules)/,
use: [
{
loader: "babel-loader"
}
]
}
]
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "node.js",
library: "subspace",
libraryTarget: "commonjs2"
},
optimization: {
usedExports: true,
sideEffects: true
},
plugins: [
new AddModuleExportsPlugin()
]
};
2019-08-23 18:31:50 +00:00
module.exports = {
node,
web,
react
2019-08-23 18:31:50 +00:00
};