Я пытаюсь создать свое электронное приложение с помощью электронного компоновщика, команда запуска - "сборка запуска пряжи". Значение process.env.NODE_ENV - это всегда «разработка», даже в производстве. Я попытался установить в package. json, под сценариями префикс NODE_ENV = production перед командой build, фактическое значение по-прежнему «development» вместо «production». Как исправить ошибку NODE_ENV в зависимости от среды? Большое спасибо.
пакет. json прикреплен ниже.
{
"main": "./dist/electron/main.js",
"scripts": {
"build:mac": "node .electron-vue/build.js && electron-builder",
"build:dir": "node .electron-vue/build.js && electron-builder --dir",
"build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
"build:web": "NODE_ENV=production cross-env BUILD_TARGET=web node .electron-vue/build.js",
"dev": "ELECTRON_ENV=development node .electron-vue/dev-runner.js",
"staging": "ELECTRON_ENV=staging node .electron-vue/dev-runner.js",
"win-dev": "node .electron-vue/dev-runner.js",
"e2e": "npm run pack && mocha test/e2e",
"lint": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter src test",
"lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter --fix src test",
"pack": "npm run pack:main && npm run pack:renderer",
"pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
"pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
"test": "npm run unit && npm run e2e",
"unit": "karma start test/unit/karma.conf.js",
"deploy": "NODE_ENV=production electron-builder --mac --win --publish always",
"deploy-mac": "NODE_ENV=production electron-builder --mac --publish always",
"build": "NODE_ENV=production electron-builder build --mac --publish never",
"postinstall": "npm run lint:fix"
},
"build": {
"directories": {
"output": "build"
},
"afterSign": "build/scripts/notarize.js",
"files": [
"dist/electron/**/*"
],
"dmg": {
"contents": [
{
"x": 410,
"y": 150,
"type": "link",
"path": "/Applications"
},
{
"x": 130,
"y": 150,
"type": "file"
}
],
"sign": false
},
"mac": {
"target": [
"dmg",
"zip"
],
"icon": "static/icons/icon.icns",
"hardenedRuntime": true,
"gatekeeperAssess": false,
"entitlements": "build/entitlements.mac.plist",
"entitlementsInherit": "build/entitlements.mac.plist"
},
"win": {
"icon": "static/icons/icon.ico"
},
"linux": {
"icon": "static/icons/icon.png"
}
},
"dependencies": {
"@sentry/electron": "1.0.0",
"auto-launch": "^5.0.5",
"axios": "^0.18.1",
"axios-response-logger": "^0.1.0",
"base64-arraybuffer": "^0.2.0",
"csv-parser": "^2.3.1",
"dropbox": "^4.0.30",
"electron-log": "^4.0.1",
"electron-notarize": "^0.2.1",
"electron-packager": "^14.0.6",
"electron-transparency-mouse-fix": "^1.0.0-rc.1",
"electron-window-state": "^5.0.3",
"filestack-js": "^3.7.0",
"firebase": "^7.1.0",
"geometric": "^2.2.0",
"kalmanjs": "^1.1.0",
"rollup": "^1.15.6",
"universal-analytics": "^0.4.20",
"vue": "^2.5.16",
"vue-electron": "^1.0.6",
"vue-router": "^3.0.1",
"vuex": "^3.0.1",
"vuex-electron": "^1.0.0"
},
"devDependencies": {
"ajv": "^6.5.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-loader": "^7.1.4",
"babel-plugin-istanbul": "^4.1.6",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.26.0",
"babili-webpack-plugin": "^0.1.2",
"cfonts": "^2.1.2",
"chai": "^4.1.2",
"chalk": "^2.4.1",
"copy-webpack-plugin": "^4.5.1",
"cross-env": "^5.1.6",
"css-loader": "^0.28.11",
"del": "^3.0.0",
"devtron": "^1.4.0",
"electron": "6.0.10",
"electron-builder": "^22.2.0",
"electron-debug": "^1.5.0",
"electron-devtools-installer": "^2.2.4",
"electron-rebuild": "^1.8.5",
"electron-updater": "4.2.0",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.0.0",
"eslint-plugin-html": "^4.0.3",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0",
"inject-loader": "^4.0.1",
"karma": "^2.0.2",
"karma-chai": "^0.1.0",
"karma-coverage": "^1.1.2",
"karma-electron": "^6.0.0",
"karma-mocha": "^1.3.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^3.0.0",
"mini-css-extract-plugin": "0.4.0",
"mocha": "^5.2.0",
"multispinner": "^0.2.1",
"node-loader": "^0.6.0",
"node-sass": "^4.9.2",
"require-dir": "^1.0.0",
"sass-loader": "^7.0.3",
"spectron": "^3.8.0",
"style-loader": "^0.21.0",
"url-loader": "^1.0.1",
"vue-html-loader": "^1.2.4",
"vue-loader": "^15.2.4",
"vue-style-loader": "^4.1.0",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.15.1",
"webpack-bundle-analyzer": "^3.6.0",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4",
"webpack-hot-middleware": "^2.22.2",
"webpack-merge": "^4.1.3"
}
}