fix: webpack env config (#12)
This commit is contained in:
parent
3e7cdbcac1
commit
ca20d541ad
|
@ -11,7 +11,9 @@
|
||||||
"babel:node": "npm-run-all babel:node:*",
|
"babel:node": "npm-run-all babel:node:*",
|
||||||
"babel:node:src": "cross-env BABEL_ENV=node babel src --copy-files --extensions \".js\" --out-dir dist",
|
"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:dev": "webpack --config webpack.dev.js",
|
||||||
|
"webpack:prod": "webpack --config webpack.prod.js",
|
||||||
"build:dev": "npm-run-all babel:node webpack:dev",
|
"build:dev": "npm-run-all babel:node webpack:dev",
|
||||||
|
"build:prod": "npm-run-all babel:node webpack:prod",
|
||||||
"build": "npm-run-all build:dev",
|
"build": "npm-run-all build:dev",
|
||||||
"clean": "rimraf dist"
|
"clean": "rimraf dist"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const webConfig = {
|
const web = {
|
||||||
target: 'web',
|
target: 'web',
|
||||||
entry: path.join(__dirname, "src/index.js"),
|
entry: path.join(__dirname, "dist/index.js"),
|
||||||
externals: ['electron'],
|
externals: ['electron'],
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, "dist"),
|
path: path.resolve(__dirname, "dist"),
|
||||||
|
@ -12,13 +12,16 @@ const webConfig = {
|
||||||
},
|
},
|
||||||
node: {
|
node: {
|
||||||
fs: 'empty',
|
fs: 'empty',
|
||||||
|
},
|
||||||
|
optimization: {
|
||||||
|
usedExports: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeConfig = {
|
const node = {
|
||||||
target: "node",
|
target: "node",
|
||||||
externals: ['electron'],
|
externals: ['electron'],
|
||||||
entry: path.join(__dirname, "src/eventSyncer.js"),
|
entry: path.join(__dirname, "dist/eventSyncer.js"),
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, "dist"),
|
path: path.resolve(__dirname, "dist"),
|
||||||
filename: "node.js",
|
filename: "node.js",
|
||||||
|
@ -27,4 +30,7 @@ const nodeConfig = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = [nodeConfig, webConfig];
|
module.exports = {
|
||||||
|
node,
|
||||||
|
web
|
||||||
|
};
|
||||||
|
|
|
@ -2,8 +2,13 @@
|
||||||
const merge = require("webpack-merge");
|
const merge = require("webpack-merge");
|
||||||
const common = require("./webpack.common.js");
|
const common = require("./webpack.common.js");
|
||||||
|
|
||||||
// TODO: use merge
|
const mode = "development";
|
||||||
common[0].mode = "development";
|
|
||||||
common[1].mode = "development";
|
|
||||||
|
|
||||||
module.exports = common;
|
module.exports = merge.multiple(common, {
|
||||||
|
web: {
|
||||||
|
mode
|
||||||
|
},
|
||||||
|
node: {
|
||||||
|
mode
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue