fix: webpack env config (#12)

This commit is contained in:
Richard Ramos 2019-08-23 14:31:50 -04:00 committed by GitHub
parent 3e7cdbcac1
commit ca20d541ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 9 deletions

View File

@ -11,7 +11,9 @@
"babel:node": "npm-run-all babel:node:*",
"babel:node:src": "cross-env BABEL_ENV=node babel src --copy-files --extensions \".js\" --out-dir dist",
"webpack:dev": "webpack --config webpack.dev.js",
"webpack:prod": "webpack --config webpack.prod.js",
"build:dev": "npm-run-all babel:node webpack:dev",
"build:prod": "npm-run-all babel:node webpack:prod",
"build": "npm-run-all build:dev",
"clean": "rimraf dist"
},

View File

@ -1,8 +1,8 @@
const path = require('path');
const webConfig = {
const web = {
target: 'web',
entry: path.join(__dirname, "src/index.js"),
entry: path.join(__dirname, "dist/index.js"),
externals: ['electron'],
output: {
path: path.resolve(__dirname, "dist"),
@ -12,13 +12,16 @@ const webConfig = {
},
node: {
fs: 'empty',
},
optimization: {
usedExports: true
}
};
const nodeConfig = {
const node = {
target: "node",
externals: ['electron'],
entry: path.join(__dirname, "src/eventSyncer.js"),
entry: path.join(__dirname, "dist/eventSyncer.js"),
output: {
path: path.resolve(__dirname, "dist"),
filename: "node.js",
@ -27,4 +30,7 @@ const nodeConfig = {
}
};
module.exports = [nodeConfig, webConfig];
module.exports = {
node,
web
};

View File

@ -2,8 +2,13 @@
const merge = require("webpack-merge");
const common = require("./webpack.common.js");
// TODO: use merge
common[0].mode = "development";
common[1].mode = "development";
const mode = "development";
module.exports = common;
module.exports = merge.multiple(common, {
web: {
mode
},
node: {
mode
}
});

14
webpack.prod.js Normal file
View File

@ -0,0 +1,14 @@
const merge = require("webpack-merge");
const common = require("./webpack.common.js");
const mode = "production";
module.exports = merge.multiple(common, {
web: {
mode
},
node: {
mode
}
});