build(vite): make sure NODE_ENV is set for dev and prod
This commit is contained in:
+3
-2
@@ -8,7 +8,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "NODE_ENV=production nx exec --verbose -- vite build",
|
||||
"build:nominify": "yarn run build -- --env noMinify=1",
|
||||
"build:nominify": "NO_MINIFY=1 yarn run build",
|
||||
"build:stats": "NODE_ENV=production webpack --progress --config scripts/webpack/webpack.stats.js",
|
||||
"dev": "NODE_ENV=dev nx exec -- vite",
|
||||
"e2e": "./e2e/start-and-run-suite",
|
||||
@@ -42,7 +42,7 @@
|
||||
"prettier:check": "prettier --check --list-different=false --log-level=warn \"**/*.{ts,tsx,scss,md,mdx,json,js}\"",
|
||||
"prettier:checkDocs": "prettier --check --list-different=false --log-level=warn \"docs/**/*.md\" \"*.md\" \"packages/**/*.{ts,tsx,scss,md,mdx,json}\"",
|
||||
"prettier:write": "prettier --list-different \"**/*.{js,ts,tsx,scss,md,mdx,json}\" --write",
|
||||
"start": "NODE_ENV=dev nx exec -- vite",
|
||||
"start": "NODE_ENV=development nx exec -- vite",
|
||||
"start:liveReload": "yarn start -- --env liveReload=1",
|
||||
"start:noTsCheck": "yarn start -- --env noTsCheck=1",
|
||||
"start:noLint": "yarn start -- --env noTsCheck=1 --env noLint=1",
|
||||
@@ -229,6 +229,7 @@
|
||||
"ts-node": "10.9.2",
|
||||
"typescript": "5.7.3",
|
||||
"vite": "5.1.5",
|
||||
"vite-plugin-environment": "^1.1.3",
|
||||
"webpack": "5.97.1",
|
||||
"webpack-cli": "5.1.4",
|
||||
"yaml": "^2.0.0",
|
||||
|
||||
+9
-3
@@ -5,11 +5,13 @@ import { resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { visualizer } from 'rollup-plugin-visualizer';
|
||||
import { defineConfig, splitVendorChunkPlugin, type PluginOption } from 'vite';
|
||||
import EnvironmentPlugin from 'vite-plugin-environment';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const shouldMinify = process.env.NO_MINIFY === '1' ? false : 'esbuild';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
export default defineConfig(({ command }) => ({
|
||||
root: 'public',
|
||||
build: {
|
||||
// use manifest for backend integration in production
|
||||
@@ -19,7 +21,7 @@ export default defineConfig({
|
||||
},
|
||||
outDir: 'build_tmp',
|
||||
assetsDir: 'public/build',
|
||||
minify: 'esbuild',
|
||||
minify: shouldMinify,
|
||||
},
|
||||
server: {
|
||||
// vite binds to ipv6 by default... and that doesn't work for me locally on mac...
|
||||
@@ -30,6 +32,10 @@ export default defineConfig({
|
||||
react(),
|
||||
splitVendorChunkPlugin(),
|
||||
angularHtmlImport(),
|
||||
EnvironmentPlugin({
|
||||
// these are default values in case NODE_ENV is not set in the environment
|
||||
NODE_ENV: command === 'build' ? 'production' : 'development',
|
||||
}),
|
||||
{ ...moveAssets(), apply: 'build' },
|
||||
{ ...visualizer(), apply: 'build' } as PluginOption,
|
||||
],
|
||||
@@ -86,7 +92,7 @@ export default defineConfig({
|
||||
return { relative: true };
|
||||
},
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
/**
|
||||
* This is a Vite plugin for handling angular templates.
|
||||
|
||||
@@ -18554,6 +18554,7 @@ __metadata:
|
||||
uuid: "npm:11.0.5"
|
||||
visjs-network: "npm:4.25.0"
|
||||
vite: "npm:5.1.5"
|
||||
vite-plugin-environment: "npm:^1.1.3"
|
||||
webpack: "npm:5.97.1"
|
||||
webpack-cli: "npm:5.1.4"
|
||||
whatwg-fetch: "npm:3.6.20"
|
||||
@@ -30894,6 +30895,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"vite-plugin-environment@npm:^1.1.3":
|
||||
version: 1.1.3
|
||||
resolution: "vite-plugin-environment@npm:1.1.3"
|
||||
peerDependencies:
|
||||
vite: ">= 2.7"
|
||||
checksum: 10/8e15190dc34d005c5132431b50eb15e85443a567a3325251fb12503a19c0b75b8907f85d0f18249970ccbba2fdfa60fd6ba01e917049ea77081d7e33c862e388
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"vite@npm:5.1.5":
|
||||
version: 5.1.5
|
||||
resolution: "vite@npm:5.1.5"
|
||||
|
||||
Reference in New Issue
Block a user