diff --git a/package.json b/package.json index b6a85eb..131e34c 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/webpack.common.js b/webpack.common.js index b3dbaf6..65c0dae 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -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 +}; diff --git a/webpack.dev.js b/webpack.dev.js index e14f928..deca34c 100644 --- a/webpack.dev.js +++ b/webpack.dev.js @@ -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; \ No newline at end of file +module.exports = merge.multiple(common, { + web: { + mode + }, + node: { + mode + } +}); diff --git a/webpack.prod.js b/webpack.prod.js new file mode 100644 index 0000000..ff70eb2 --- /dev/null +++ b/webpack.prod.js @@ -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 + } +});