Skip to content

Commit

Permalink
build: update watch methods and include css in build
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Sep 27, 2024
1 parent 26bb118 commit 1f50edc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
7 changes: 4 additions & 3 deletions apps/delivery-options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"build:dev": "run build:default:dev && run build:myparcel:dev && run build:myparcel-lib:dev",
"build:myparcel": "vite build -c vite-myparcel.config.ts",
"build:myparcel-lib": "vite build -c vite-myparcel-lib.config.ts",
"build:myparcel-lib:dev": "run build:myparcel-lib -- --mode development",
"build:myparcel:dev": "run build:myparcel -- --mode development",
"build:myparcel-lib:dev": "BUILD_CSS=1 run build:myparcel-lib -- --mode development",
"build:myparcel:dev": "BUILD_CSS=1 run build:myparcel -- --mode development",
"clean": "run ws:clean \"$(pwd)\"",
"lint": "run ws:lint \"$(pwd)\"",
"lint:fix": "run ws:lint:fix \"$(pwd)\"",
Expand All @@ -46,7 +46,8 @@
"test:run": "run ws:test:run \"$(pwd)\"",
"test:update": "run ws:test:update \"$(pwd)\"",
"typecheck": "vue-tsc --project tsconfig.base.json --noEmit",
"watch": "vite build -c vite-myparcel-lib.config.ts --mode development --watch"
"watch:myparcel": "BUILD_CSS=1 vite build -c vite-myparcel-lib.config.ts --watch --mode development",
"watch:myparcel-lib": "BUILD_CSS=1 vite build -c vite-myparcel.config.ts --watch --mode development"
},
"dependencies": {
"@myparcel-do/shared": "workspace:*",
Expand Down
33 changes: 23 additions & 10 deletions apps/delivery-options/private/skipCssPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import {type Plugin} from 'vite';
import {type Plugin, createLogger} from 'vite';

export const skipCssPlugin = (): Plugin => ({
name: 'skip-css',
transform(_, id) {
if (id.endsWith('.scss') || id.endsWith('.css')) {
return '';
}
const PLUGIN_NAME = 'skip-css';
export const skipCssPlugin = (): Plugin => {
const buildAnyway = Boolean(process.env.BUILD_CSS ?? false);

const logger = createLogger(undefined, {prefix: PLUGIN_NAME});

if (buildAnyway) {
logger.info('Building CSS files because BUILD_CSS is set.');
}

return null;
},
});
return {
name: PLUGIN_NAME,
transform(_, id) {
const isCssFile = id.endsWith('.scss') || id.endsWith('.css');

if (buildAnyway || !isCssFile) {
return null;
}

return '';
},
};
};
1 change: 1 addition & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"{projectRoot}/*.json",
"{projectRoot}/*.mjs",
"{projectRoot}/*.ts",
"{projectRoot}/private/**/*",
"{projectRoot}/public/**/*",
"{projectRoot}/src/**/*",
"!{projectRoot}/release.config.cjs",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"test:update": "nx run-many -t test:update --output-style=stream",
"translations:import": "yarn workspace @myparcel-do/sandbox run translations:import",
"typecheck": "nx run-many -t typecheck",
"watch": "nx run-many -t watch --output-style=stream --parallel=99",
"watch": "nx run-many -t watch:myparcel --output-style=stream --parallel=99",
"watch:lib": "nx run-many -t watch:myparcel-lib --output-style=stream --parallel=99",
"ws:clean": "cd $0 && rimraf dist coverage .eslintcache tsconfig.build.tsbuildinfo",
"ws:lint": "eslint --cache $0",
"ws:lint:fix": "eslint --cache --fix $0",
Expand Down

0 comments on commit 1f50edc

Please sign in to comment.