Skip to content

Commit

Permalink
add lint script, change webpack mode by NODE_ENV (lensapp#30)
Browse files Browse the repository at this point in the history
* Add lint script

* Add NODE_ENV before npm start/npm run build

* Add mode which takes NODE_ENV and enable devtool for development env

* Enable source map for main alos

* Update test snapshot

* @k8slens/extensions to 4.2.1

* Update test snapshot
  • Loading branch information
chenhunghan authored Apr 14, 2021
1 parent 3ad2cd9 commit bc1bf2f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
7 changes: 4 additions & 3 deletions generators/app/templates/ext-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
"kubernetes"
],
"scripts": {
"start": "webpack --watch",
"build": "npm run clean && webpack",
"start": "NODE_ENV=development webpack --watch",
"build": "npm run clean && NODE_ENV=production webpack",
"clean": "rm -rf ./dist",
"test": "jest"
"lint": "eslint",
"test": "npm run lint && jest"
},
"dependencies": {
<%- dep("react") %>,
Expand Down
8 changes: 6 additions & 2 deletions generators/app/templates/ext-ts/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ module.exports = [
entry: "./main.ts",
context: __dirname,
target: "electron-main",
mode: "production",
mode: process.env.NODE_ENV ?? "production",
// Only enable source map in development mode
devtool: process.env.NODE_ENV === "development" && "eval-source-map",
module: {
rules: [
{
Expand Down Expand Up @@ -37,7 +39,9 @@ module.exports = [
entry: "./renderer.tsx",
context: __dirname,
target: "electron-renderer",
mode: "production",
mode: process.env.NODE_ENV ?? "production",
// Only enable source map in development mode
devtool: process.env.NODE_ENV === "development" && "eval-source-map",
module: {
rules: [
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"yosay": "^2.0.2"
},
"devDependencies": {
"@k8slens/extensions": "^4.1.3",
"@k8slens/extensions": "^4.2.1",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@types/jest": "^26.0.15",
Expand Down
9 changes: 5 additions & 4 deletions test/__snapshots__/ext-ts.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Object {
"@babel/preset-react": "^7.12.7",
"@babel/preset-typescript": "^7.12.7",
"@jest-runner/electron": "^3.0.0",
"@k8slens/extensions": "^4.1.3",
"@k8slens/extensions": "^4.2.1",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@types/jest": "^26.0.15",
Expand Down Expand Up @@ -56,10 +56,11 @@ Object {
"publisher": "random publisher",
"renderer": "dist/renderer.js",
"scripts": Object {
"build": "npm run clean && webpack",
"build": "npm run clean && NODE_ENV=production webpack",
"clean": "rm -rf ./dist",
"start": "webpack --watch",
"test": "jest",
"lint": "eslint",
"start": "NODE_ENV=development webpack --watch",
"test": "npm run lint && jest",
},
"version": "0.0.1",
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,10 @@
"@types/yargs" "^15.0.0"
chalk "^4.0.0"

"@k8slens/extensions@^4.1.3":
version "4.1.3"
resolved "https://registry.yarnpkg.com/@k8slens/extensions/-/extensions-4.1.3.tgz#18bcb85b67bd479dfe03923afc1bca061efa6378"
integrity sha512-gDLC1fxpKPmgPxkZ3tZvqtLK146GoC/IvVgIPEIZpQWozNY+kvjqQ3KArzG+HplFiALpFatav+3eDw8m2EmgAw==
"@k8slens/extensions@^4.2.1":
version "4.2.1"
resolved "https://registry.yarnpkg.com/@k8slens/extensions/-/extensions-4.2.1.tgz#5744a4dd1ead3c8b1888bec6fb099de0c676937a"
integrity sha512-/tttsgNqV3uDxfAixMNx+anKvzyAhLgEzrBM3XZH3RYbLlATkps8X0R4bkhg9IRvkJh2i9tem7s1hkuL7efKwg==
dependencies:
"@material-ui/core" "*"
"@types/node" "*"
Expand Down

0 comments on commit bc1bf2f

Please sign in to comment.