Fix tree shaking trigger for vite

This commit is contained in:
Jérémy Munsch 2024-02-21 12:27:33 +01:00
parent 708019fe4f
commit c563f0ee2c
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC
2 changed files with 20 additions and 16 deletions

View file

@ -4,8 +4,8 @@
"scripts": {
"vite": "vite --clearScreen false",
"prod": "vite build --mode production",
"dev": "NODE_ENV=development vite build -d --mode development",
"watch": "NODE_ENV=development vite build --mode development --watch",
"dev": "vite build --mode development -d",
"watch": "vite build --mode development --watch",
"eslint": "node ./node_modules/.bin/eslint --max-warnings 0 -c .eslintrc.json ./resources",
"eslint-fix": "node ./node_modules/.bin/eslint --fix --max-warnings 0 -c .eslintrc.json ./resources",
"eslint-ci": "node ./node_modules/.bin/eslint --max-warnings 0 -c .eslintrc.json ./resources -f junit",

View file

@ -6,7 +6,7 @@ import laravel from "laravel-vite-plugin";
import path from "path";
import postcssDiscard from "postcss-discard-comments";
import copy from "rollup-plugin-copy";
import { defineConfig, loadEnv } from "vite";
import { ConfigEnv, UserConfig, defineConfig, loadEnv } from "vite";
import babel from "vite-plugin-babel";
import checker from "vite-plugin-checker";
import eslint from "vite-plugin-eslint";
@ -14,6 +14,22 @@ import stylelint from "vite-plugin-stylelint";
const env = loadEnv("r", process.cwd(), "");
const purgePlugin = purge({
templates: ["blade"],
paths: [
"resources/{js,ts,views}/**/*.{ts,js,vue}"
],
safelist: [
// Bootstrap
/^cropper-/, /^offcanvas-/, /^tooltip/, /^bs-tooltip/, /^data-popper/, /.*\[data-popper-placement].*/,
/^bs-popover/, /^popover/,
// Vue
/-(leave|enter|appear)(|-(to|from|active))$/, /^(?!(|.*?:)cursor-move).+-move$/, /^router-link(|-exact)-active$/, /data-v-.*/
],
});
purgePlugin.apply = (config: UserConfig, env: ConfigEnv) => env.mode === "production";
export default defineConfig({
build: {
rollupOptions: {
@ -141,19 +157,7 @@ export default defineConfig({
isProduction: process.env.NODE_ENV !== "local" ? true : false,
exclude: ["node_modules", "vendor"],
}),
purge({
templates: ["blade"],
paths: [
"resources/{js,ts,views}/**/*.{ts,js,vue}"
],
safelist: [
// Bootstrap
/^cropper-/, /^offcanvas-/, /^tooltip/, /^bs-tooltip/, /^data-popper/, /.*\[data-popper-placement].*/,
/^bs-popover/, /^popover/,
// Vue
/-(leave|enter|appear)(|-(to|from|active))$/, /^(?!(|.*?:)cursor-move).+-move$/, /^router-link(|-exact)-active$/, /data-v-.*/
],
})
purgePlugin
],
server: {
https: true,