environment is added

This commit is contained in:
richard-loafle 2020-03-27 18:04:12 +09:00
parent c17f98928c
commit 1f24033b98
5 changed files with 295 additions and 4 deletions

15
config/enviroment.js Normal file
View File

@ -0,0 +1,15 @@
const channel = process.env.NODE_ENV;
const s = JSON.stringify;
module.exports = function() {
return {
__DARWIN__: process.platform === 'darwin',
__WIN32__: process.platform === 'win32',
__LINUX__: process.platform === 'linux',
__DEV__: channel === 'development',
'process.platform': s(process.platform),
'process.env.NODE_ENV': s(process.env.NODE_ENV || 'development'),
'process.env.TEST_ENV': s(process.env.TEST_ENV)
};
};

View File

@ -1,12 +1,21 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack');
const webpackNodeExternals = require('webpack-node-externals'); const webpackNodeExternals = require('webpack-node-externals');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const getEnviroment = require('./enviroment');
const rootPath = path.join(__dirname, '..'); const rootPath = path.join(__dirname, '..');
const enviroment = getEnviroment();
module.exports = [ module.exports = [
{ {
mode: process.env.ENV || 'development', mode: process.env.ENV || 'development',
entry: path.join(rootPath, 'src', 'main'), entry: path.join(rootPath, 'src', 'main'),
output: {
path: path.join(rootPath, 'dist'),
filename: 'electron-main.js'
},
target: 'electron-main', target: 'electron-main',
devtool: 'source-map', devtool: 'source-map',
externals: [webpackNodeExternals()], externals: [webpackNodeExternals()],
@ -29,9 +38,9 @@ module.exports = [
} }
] ]
}, },
output: { plugins: [
path: path.join(rootPath, 'dist'), new CleanWebpackPlugin({ verbose: false }),
filename: 'electron-main.js' new webpack.DefinePlugin(Object.assign({}, enviroment, {}))
} ]
} }
]; ];

253
package-lock.json generated
View File

@ -278,6 +278,12 @@
"tslib": "1.11.1" "tslib": "1.11.1"
} }
}, },
"@types/anymatch": {
"version": "1.3.1",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/anymatch/-/anymatch-1.3.1.tgz",
"integrity": "sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==",
"dev": true
},
"@types/color-name": { "@types/color-name": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/color-name/-/color-name-1.1.1.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/color-name/-/color-name-1.1.1.tgz",
@ -289,6 +295,12 @@
"integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==", "integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==",
"dev": true "dev": true
}, },
"@types/events": {
"version": "3.0.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/events/-/events-3.0.0.tgz",
"integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==",
"dev": true
},
"@types/fs-extra": { "@types/fs-extra": {
"version": "8.1.0", "version": "8.1.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/fs-extra/-/fs-extra-8.1.0.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/fs-extra/-/fs-extra-8.1.0.tgz",
@ -298,6 +310,17 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@types/glob": {
"version": "7.1.1",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/glob/-/glob-7.1.1.tgz",
"integrity": "sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w==",
"dev": true,
"requires": {
"@types/events": "*",
"@types/minimatch": "*",
"@types/node": "*"
}
},
"@types/jasmine": { "@types/jasmine": {
"version": "3.5.10", "version": "3.5.10",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/jasmine/-/jasmine-3.5.10.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/jasmine/-/jasmine-3.5.10.tgz",
@ -313,6 +336,12 @@
"@types/jasmine": "*" "@types/jasmine": "*"
} }
}, },
"@types/minimatch": {
"version": "3.0.3",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/minimatch/-/minimatch-3.0.3.tgz",
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
"dev": true
},
"@types/node": { "@types/node": {
"version": "12.12.31", "version": "12.12.31",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/node/-/node-12.12.31.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/node/-/node-12.12.31.tgz",
@ -338,6 +367,52 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@types/source-list-map": {
"version": "0.1.2",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/source-list-map/-/source-list-map-0.1.2.tgz",
"integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==",
"dev": true
},
"@types/tapable": {
"version": "1.0.5",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/tapable/-/tapable-1.0.5.tgz",
"integrity": "sha512-/gG2M/Imw7cQFp8PGvz/SwocNrmKFjFsm5Pb8HdbHkZ1K8pmuPzOX4VeVoiEecFCVf4CsN1r3/BRvx+6sNqwtQ==",
"dev": true
},
"@types/uglify-js": {
"version": "3.0.4",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/uglify-js/-/uglify-js-3.0.4.tgz",
"integrity": "sha512-SudIN9TRJ+v8g5pTG8RRCqfqTMNqgWCKKd3vtynhGzkIIjxaicNAMuY5TRadJ6tzDu3Dotf3ngaMILtmOdmWEQ==",
"dev": true,
"requires": {
"source-map": "^0.6.1"
}
},
"@types/webpack": {
"version": "4.41.8",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/webpack/-/webpack-4.41.8.tgz",
"integrity": "sha512-mh4litLHTlDG84TGCFv1pZldndI34vkrW9Mks++Zx4KET7DRMoCXUvLbTISiuF4++fMgNnhV9cc1nCXJQyBYbQ==",
"dev": true,
"requires": {
"@types/anymatch": "*",
"@types/node": "*",
"@types/tapable": "*",
"@types/uglify-js": "*",
"@types/webpack-sources": "*",
"source-map": "^0.6.0"
}
},
"@types/webpack-sources": {
"version": "0.1.7",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/webpack-sources/-/webpack-sources-0.1.7.tgz",
"integrity": "sha512-XyaHrJILjK1VHVC4aVlKsdNN5KBTwufMb43cQs+flGxtPAf/1Qwl8+Q0tp5BwEGaI8D6XT1L+9bSWXckgkjTLw==",
"dev": true,
"requires": {
"@types/node": "*",
"@types/source-list-map": "*",
"source-map": "^0.6.1"
}
},
"@types/yargs": { "@types/yargs": {
"version": "15.0.4", "version": "15.0.4",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/yargs/-/yargs-15.0.4.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/@types/yargs/-/yargs-15.0.4.tgz",
@ -633,6 +708,12 @@
} }
} }
}, },
"ansi-colors": {
"version": "3.2.4",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/ansi-colors/-/ansi-colors-3.2.4.tgz",
"integrity": "sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==",
"dev": true
},
"ansi-regex": { "ansi-regex": {
"version": "4.1.0", "version": "4.1.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/ansi-regex/-/ansi-regex-4.1.0.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/ansi-regex/-/ansi-regex-4.1.0.tgz",
@ -1535,6 +1616,84 @@
} }
} }
}, },
"clean-webpack-plugin": {
"version": "3.0.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/clean-webpack-plugin/-/clean-webpack-plugin-3.0.0.tgz",
"integrity": "sha512-MciirUH5r+cYLGCOL5JX/ZLzOZbVr1ot3Fw+KcvbhUb6PM+yycqd9ZhIlcigQ5gl+XhppNmw3bEFuaaMNyLj3A==",
"dev": true,
"requires": {
"@types/webpack": "^4.4.31",
"del": "^4.1.1"
},
"dependencies": {
"del": {
"version": "4.1.1",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/del/-/del-4.1.1.tgz",
"integrity": "sha512-QwGuEUouP2kVwQenAsOof5Fv8K9t3D8Ca8NxcXKrIpEHjTXK5J2nXLdP+ALI1cgv8wj7KuwBhTwBkOZSJKM5XQ==",
"dev": true,
"requires": {
"@types/glob": "^7.1.1",
"globby": "^6.1.0",
"is-path-cwd": "^2.0.0",
"is-path-in-cwd": "^2.0.0",
"p-map": "^2.0.0",
"pify": "^4.0.1",
"rimraf": "^2.6.3"
}
},
"globby": {
"version": "6.1.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/globby/-/globby-6.1.0.tgz",
"integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=",
"dev": true,
"requires": {
"array-union": "^1.0.1",
"glob": "^7.0.3",
"object-assign": "^4.0.1",
"pify": "^2.0.0",
"pinkie-promise": "^2.0.0"
},
"dependencies": {
"pify": {
"version": "2.3.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}
}
},
"is-path-cwd": {
"version": "2.2.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/is-path-cwd/-/is-path-cwd-2.2.0.tgz",
"integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==",
"dev": true
},
"is-path-in-cwd": {
"version": "2.1.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/is-path-in-cwd/-/is-path-in-cwd-2.1.0.tgz",
"integrity": "sha512-rNocXHgipO+rvnP6dk3zI20RpOtrAM/kzbB258Uw5BWr3TpXi861yzjo16Dn4hUox07iw5AyeMLHWsujkjzvRQ==",
"dev": true,
"requires": {
"is-path-inside": "^2.1.0"
}
},
"is-path-inside": {
"version": "2.1.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/is-path-inside/-/is-path-inside-2.1.0.tgz",
"integrity": "sha512-wiyhTzfDWsvwAW53OBWF5zuvaOGlZ6PwYxAbPVDhpm+gM09xKQGjBq/8uYN12aDvMxnAnq3dxTyoSoRNmg5YFg==",
"dev": true,
"requires": {
"path-is-inside": "^1.0.2"
}
},
"pify": {
"version": "4.0.1",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
"dev": true
}
}
},
"cli-boxes": { "cli-boxes": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/cli-boxes/-/cli-boxes-2.2.0.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/cli-boxes/-/cli-boxes-2.2.0.tgz",
@ -1791,6 +1950,63 @@
"integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=",
"dev": true "dev": true
}, },
"copy-webpack-plugin": {
"version": "5.1.1",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/copy-webpack-plugin/-/copy-webpack-plugin-5.1.1.tgz",
"integrity": "sha512-P15M5ZC8dyCjQHWwd4Ia/dm0SgVvZJMYeykVIVYXbGyqO4dWB5oyPHp9i7wjwo5LhtlhKbiBCdS2NvM07Wlybg==",
"dev": true,
"requires": {
"cacache": "^12.0.3",
"find-cache-dir": "^2.1.0",
"glob-parent": "^3.1.0",
"globby": "^7.1.1",
"is-glob": "^4.0.1",
"loader-utils": "^1.2.3",
"minimatch": "^3.0.4",
"normalize-path": "^3.0.0",
"p-limit": "^2.2.1",
"schema-utils": "^1.0.0",
"serialize-javascript": "^2.1.2",
"webpack-log": "^2.0.0"
},
"dependencies": {
"glob-parent": {
"version": "3.1.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/glob-parent/-/glob-parent-3.1.0.tgz",
"integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=",
"dev": true,
"requires": {
"is-glob": "^3.1.0",
"path-dirname": "^1.0.0"
},
"dependencies": {
"is-glob": {
"version": "3.1.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/is-glob/-/is-glob-3.1.0.tgz",
"integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=",
"dev": true,
"requires": {
"is-extglob": "^2.1.0"
}
}
}
},
"globby": {
"version": "7.1.1",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/globby/-/globby-7.1.1.tgz",
"integrity": "sha1-+yzP+UAfhgCUXfral0QMypcrhoA=",
"dev": true,
"requires": {
"array-union": "^1.0.1",
"dir-glob": "^2.0.0",
"glob": "^7.1.2",
"ignore": "^3.3.5",
"pify": "^3.0.0",
"slash": "^1.0.0"
}
}
}
},
"core-js": { "core-js": {
"version": "3.6.4", "version": "3.6.4",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/core-js/-/core-js-3.6.4.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/core-js/-/core-js-3.6.4.tgz",
@ -2118,6 +2334,15 @@
"randombytes": "^2.0.0" "randombytes": "^2.0.0"
} }
}, },
"dir-glob": {
"version": "2.2.2",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/dir-glob/-/dir-glob-2.2.2.tgz",
"integrity": "sha512-f9LBi5QWzIW3I6e//uxZoLBlUt9kcp66qo0sSCxL6YZKc75R1c4MFCoe/LaZiBGmgujvQdxc5Bn3QhfyvK5Hsw==",
"dev": true,
"requires": {
"path-type": "^3.0.0"
}
},
"dmg-builder": { "dmg-builder": {
"version": "22.4.1", "version": "22.4.1",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/dmg-builder/-/dmg-builder-22.4.1.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/dmg-builder/-/dmg-builder-22.4.1.tgz",
@ -3840,6 +4065,12 @@
"integrity": "sha1-xg7taebY/bazEEofy8ocGS3FtQE=", "integrity": "sha1-xg7taebY/bazEEofy8ocGS3FtQE=",
"dev": true "dev": true
}, },
"ignore": {
"version": "3.3.10",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/ignore/-/ignore-3.3.10.tgz",
"integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==",
"dev": true
},
"immediate": { "immediate": {
"version": "3.0.6", "version": "3.0.6",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/immediate/-/immediate-3.0.6.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/immediate/-/immediate-3.0.6.tgz",
@ -5457,6 +5688,12 @@
"p-limit": "^2.0.0" "p-limit": "^2.0.0"
} }
}, },
"p-map": {
"version": "2.1.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/p-map/-/p-map-2.1.0.tgz",
"integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==",
"dev": true
},
"p-try": { "p-try": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/p-try/-/p-try-2.2.0.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/p-try/-/p-try-2.2.0.tgz",
@ -6526,6 +6763,12 @@
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/signal-exit/-/signal-exit-3.0.3.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/signal-exit/-/signal-exit-3.0.3.tgz",
"integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA=="
}, },
"slash": {
"version": "1.0.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/slash/-/slash-1.0.0.tgz",
"integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=",
"dev": true
},
"snapdragon": { "snapdragon": {
"version": "0.8.2", "version": "0.8.2",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/snapdragon/-/snapdragon-0.8.2.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/snapdragon/-/snapdragon-0.8.2.tgz",
@ -8995,6 +9238,16 @@
} }
} }
}, },
"webpack-log": {
"version": "2.0.0",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/webpack-log/-/webpack-log-2.0.0.tgz",
"integrity": "sha512-cX8G2vR/85UYG59FgkoMamwHUIkSSlV3bBMRsbxVXVUk2j6NleCKjQ/WE9eYg9WY4w25O9w8wKP4rzNZFmUcUg==",
"dev": true,
"requires": {
"ansi-colors": "^3.0.0",
"uuid": "^3.3.2"
}
},
"webpack-merge": { "webpack-merge": {
"version": "4.2.2", "version": "4.2.2",
"resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/webpack-merge/-/webpack-merge-4.2.2.tgz", "resolved": "http://10.81.13.221:8081/nexus/repository/npm-all/webpack-merge/-/webpack-merge-4.2.2.tgz",

View File

@ -26,6 +26,8 @@
"@types/node": "^12.11.1", "@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0", "@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "~2.0.3",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^5.1.1",
"cross-env": "^7.0.2", "cross-env": "^7.0.2",
"devtron": "^1.4.0", "devtron": "^1.4.0",
"electron": "^8.1.1", "electron": "^8.1.1",

12
src/global.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
/* eslint-disable @typescript-eslint/interface-name-prefix */
/** Is the app running in dev mode? */
declare const __DEV__: boolean;
/** Is the app being built to run on Darwin? */
declare const __DARWIN__: boolean;
/** Is the app being built to run on Win32? */
declare const __WIN32__: boolean;
/** Is the app being built to run on Linux? */
declare const __LINUX__: boolean;