Skip to content

Commit 89404e0

Browse files
committed
fix: build mode
1 parent ca36b60 commit 89404e0

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"gh:release": "conventional-github-releaser -p angular",
2424
"build": "rimraf dist && nr i18n:build && nr main:build && nr editor:build && esno scripts/post-build.ts",
2525
"dev": "run-p *:dev",
26-
"main:build": "cross-env NODE_ENV=production webpack --mode production",
26+
"main:build": "cross-env NODE_ENV=production webpack --mode development",
2727
"main:dev": "webpack --mode development --watch --info-verbosity verbose",
2828
"editor:build": "parcel build src/webview/src/index.html --out-dir dist/editor",
2929
"editor:dev": "nodemon -w src/webview/src -e js,ts,vue,html --exec \"nr editor:build\"",
@@ -78,8 +78,8 @@
7878
"@antfu/ni": "^0.7.0",
7979
"@antfu/utils": "^0.1.6",
8080
"@babel/types": "^7.14.2",
81-
"@types/chai-jest-snapshot": "^1.3.6",
8281
"@types/chai": "^4.2.18",
82+
"@types/chai-jest-snapshot": "^1.3.6",
8383
"@types/diff": "^5.0.0",
8484
"@types/fs-extra": "^9.0.11",
8585
"@types/gettext-parser": "^4.0.0",
@@ -130,7 +130,8 @@
130130
"vuex": "^3.6.2",
131131
"webpack": "^4.46.0",
132132
"webpack-cli": "^3.3.12",
133-
"webpack-filter-warnings-plugin": "^1.2.1"
133+
"webpack-filter-warnings-plugin": "^1.2.1",
134+
"webpack-plugin-replace": "^1.2.0"
134135
},
135136
"engines": {
136137
"vscode": "^1.52.0"

src/core/Config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ export class Config {
517517
static get libreTranslateApiRoot() {
518518
return this.getConfig<string | null | undefined>('translate.libre.apiRoot')
519519
}
520-
520+
521521
static get telemetry(): boolean {
522522
return workspace.getConfiguration().get('telemetry.enableTelemetry') as boolean
523523
}

src/env.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
export const isProd = process.env.NODE_ENV === 'production'
1+
// @ts-expect-error
2+
export const isProd = __PROD__
23
export const isDev = !isProd
3-
export const isTest = process.env.NODE_ENV === 'test'
4+
// @ts-expect-error
5+
export const isTest = __TEST__

webpack.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
const path = require('path')
66
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin')
77
const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin')
8+
const ReplacePlugin = require('webpack-plugin-replace')
89

910
/** @type {import('webpack').Configuration} */
1011
const config = {
@@ -56,6 +57,16 @@ const config = {
5657
new FilterWarningsPlugin({
5758
exclude: /Critical dependency: the request of a dependency is an expression/,
5859
}),
60+
new ReplacePlugin({
61+
exclude: [
62+
/node_modules/,
63+
],
64+
values: {
65+
'__PROD__': process.env.NODE_ENV === 'production',
66+
'__TEST__': process.env.NODE_ENV === 'test'
67+
}
68+
})
5969
],
6070
}
71+
6172
module.exports = config

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11150,6 +11150,11 @@ webpack-filter-warnings-plugin@^1.2.1:
1115011150
resolved "https://registry.yarnpkg.com/webpack-filter-warnings-plugin/-/webpack-filter-warnings-plugin-1.2.1.tgz#dc61521cf4f9b4a336fbc89108a75ae1da951cdb"
1115111151
integrity sha512-Ez6ytc9IseDMLPo0qCuNNYzgtUl8NovOqjIq4uAU8LTD4uoa1w1KpZyyzFtLTEMZpkkOkLfL9eN+KGYdk1Qtwg==
1115211152

11153+
webpack-plugin-replace@^1.2.0:
11154+
version "1.2.0"
11155+
resolved "https://registry.yarnpkg.com/webpack-plugin-replace/-/webpack-plugin-replace-1.2.0.tgz#3f20db96237400433231e35ea76d9be3f7128916"
11156+
integrity sha512-1HA3etHpJW55qonJqv84o5w5GY7iqF8fqSHpTWdNwarj1llkkt4jT4QSvYs1hoaU8Lu5akDnq/spHHO5mXwo1w==
11157+
1115311158
webpack-sources@^1.4.0, webpack-sources@^1.4.1:
1115411159
version "1.4.3"
1115511160
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933"

0 commit comments

Comments
 (0)