From 75aa7097d3a6fe01db64839a035fe4b35653e943 Mon Sep 17 00:00:00 2001 From: Jing Teng Date: Wed, 7 Jul 2021 15:57:03 -0400 Subject: [PATCH] able to build n launch --- package-lock.json | 3 ++- package.json | 6 +++++- quasar.conf.js | 3 --- webpack.main.config.js | 33 ++++++++++++++++++++++++++++++--- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index cf837d9256..7fcfe2b027 100644 --- a/package-lock.json +++ b/package-lock.json @@ -79,7 +79,8 @@ "prettier": "^2.2.1", "pretty-quick": "^3.1.0", "quasar": "^1.15.10", - "webpack-cli": "^4.7.2" + "webpack-cli": "^4.7.2", + "webpack-node-externals": "^2.5.2" }, "engines": { "node": ">= 8.9.0", diff --git a/package.json b/package.json index 3c16c66569..edbaee861d 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ { + "type": "commonjs", "name": "zap", "version": "0.99.6", "description": "Configuration tool for the Zigbee Cluster Library", @@ -14,6 +15,7 @@ "homepage": "https://github.com/project-chip/zap", "main": "src-electron/main-process/electron-main.js", "scripts": { + "wp": "npm run version-stamp && webpack -c webpack.main.config.js --progress", "lic": "node src-script/license-check.js --production", "lint": "eslint --ext .js,.vue src src-electron src-shared src-script test", "lintfix": "eslint --fix --ext .js,.vue src src-electron src-shared src-script test", @@ -25,6 +27,7 @@ "test:unit:watch": "jest --watch", "test:unit:watchAll": "jest --watchAll", "postinstall": "electron-builder install-app-deps && husky install", + "wpzap": "quasar build && npm run wp && npx electron ./dist/electron-main.js", "zap": "node src-script/zap-start.js --logToStdout --gen ./test/gen-template/zigbee/gen-templates.json", "zap-dev": "npm run build-spa && quasar dev -m electron", "zap-devserver": "node src-script/zap-start.js server --allowCors --logToStdout --gen ./test/gen-template/zigbee/gen-templates.json --reuseZapInstance", @@ -141,7 +144,8 @@ "prettier": "^2.2.1", "pretty-quick": "^3.1.0", "quasar": "^1.15.10", - "webpack-cli": "^4.7.2" + "webpack-cli": "^4.7.2", + "webpack-node-externals": "^2.5.2" }, "engines": { "node": ">= 8.9.0", diff --git a/quasar.conf.js b/quasar.conf.js index 8b3af5f98b..9f05365539 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -90,9 +90,6 @@ module.exports = function (ctx) { test: /\.(sql)$/, loader: 'file-loader', exclude: /node_modules/, - options: { - name: '[path][name].[ext]', - }, }) }, }, diff --git a/webpack.main.config.js b/webpack.main.config.js index 5d5f7a23e6..31414fa67e 100644 --- a/webpack.main.config.js +++ b/webpack.main.config.js @@ -1,18 +1,45 @@ const path = require('path') +const nodeExternals = require('webpack-node-externals') + const config = { + node: { + __dirname: true, + __filename: true, + }, mode: 'development', - target: 'node', + target: 'electron-main', entry: path.resolve(__dirname, 'src-electron') + '/main-process/electron-main.js', output: { path: path.resolve(__dirname, 'dist'), - filename: 'main.js', + filename: 'electron-main.js', }, module: { - rules: [{ test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' }], + rules: [ + { + enforce: 'pre', + test: /\.js$/, + loader: 'eslint-loader', + exclude: /node_modules/, + options: { + formatter: require('eslint').CLIEngine.getFormatter('stylish'), + }, + }, + { test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' }, + { + enforce: 'pre', + test: /\.(sql)$/, + loader: 'file-loader', + exclude: /node_modules/, + options: { + name: '[path][name].[ext]', + }, + }, + ], }, devtool: 'source-map', + externals: [nodeExternals()], // in order to ignore all modules in node_modules folder } module.exports = config