build: update Vite config for HMR and favicons, and update dependencies
This commit is contained in:
parent
7d4fdb3011
commit
ae2c0f146c
4 changed files with 4512 additions and 5995 deletions
10168
package-lock.json
generated
10168
package-lock.json
generated
File diff suppressed because it is too large
Load diff
95
package.json
95
package.json
|
|
@ -1,75 +1,68 @@
|
|||
{
|
||||
"private": true,
|
||||
"name": "srcs",
|
||||
"type": "module",
|
||||
"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",
|
||||
"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",
|
||||
"stylelint": "node ./node_modules/.bin/stylelint --config './.stylelintrc.json' --max-warnings 0 '**/resources/**/*.scss'",
|
||||
"stylelint-fix": "node ./node_modules/.bin/stylelint --config './.stylelintrc.json' --fix --max-warnings 0 '**/resources/**/*.scss'",
|
||||
"stylelint-ci": "node ./node_modules/.bin/stylelint --config './.stylelintrc.json' --max-warnings 0 '**/resources/**/*.scss' -f json"
|
||||
"eslint": "eslint --max-warnings 0 ./resources",
|
||||
"eslint-fix": "eslint --fix --max-warnings 0 ./resources",
|
||||
"stylelint": "stylelint --config './.stylelintrc.json' --max-warnings 0 '**/resources/**/*.scss'",
|
||||
"stylelint-fix": "stylelint --config './.stylelintrc.json' --fix --max-warnings 0 '**/resources/**/*.scss'"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.22.11",
|
||||
"@babel/types": "^7.21.2",
|
||||
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
||||
"@fortawesome/free-regular-svg-icons": "^6.5.1",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.5.1",
|
||||
"@fortawesome/vue-fontawesome": "^3.0.5",
|
||||
"@ldc-web/cookie-notice": "^6.0.3",
|
||||
"@sipec/vue3-tags-input": "^3.0.4",
|
||||
"@types/bootstrap": "^5.2.7",
|
||||
"@fortawesome/fontawesome-svg-core": "^7.3.1",
|
||||
"@fortawesome/free-brands-svg-icons": "^7.3.1",
|
||||
"@fortawesome/free-regular-svg-icons": "^7.3.1",
|
||||
"@fortawesome/free-solid-svg-icons": "^7.3.1",
|
||||
"@fortawesome/vue-fontawesome": "^3.3.2",
|
||||
"@types/bootstrap": "^5.2.11",
|
||||
"@types/node": "^20.8.2",
|
||||
"@types/toastify-js": "^1.12.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||
"@typescript-eslint/parser": "^5.36.2",
|
||||
"@vitejs/plugin-basic-ssl": "^1.0.1",
|
||||
"@vitejs/plugin-vue": "^4.6.2",
|
||||
"@vitejs/plugin-basic-ssl": "^2.3.0",
|
||||
"@vitejs/plugin-vue": "^6.0.7",
|
||||
"@vue/compiler-sfc": "latest",
|
||||
"@vue/eslint-config-typescript": "latest",
|
||||
"@vue/tsconfig": "^0.4.0",
|
||||
"axios": "^1.5.1",
|
||||
"bootstrap": "^5.3.2",
|
||||
"@vue/eslint-config-typescript": "^14.7.0",
|
||||
"@vue/tsconfig": "^0.9.1",
|
||||
"autoprefixer": "^10.5.0",
|
||||
"eslint": "^10.4.1",
|
||||
"eslint-import-resolver-typescript": "^3.6.3",
|
||||
"eslint-plugin-import-x": "^4.17.1",
|
||||
"eslint-plugin-vue": "^10.9.2",
|
||||
"laravel-vite-plugin": "^3.1.3",
|
||||
"postcss": "^8.5.15",
|
||||
"postcss-discard-comments": "^7.0.8",
|
||||
"sass-embedded": "^1.100.0",
|
||||
"stylelint": "^17.12.0",
|
||||
"stylelint-config-idiomatic-order": "github:ream88/stylelint-config-idiomatic-order",
|
||||
"stylelint-config-sass-guidelines": "^13.0.0",
|
||||
"stylelint-config-standard-scss": "^17.0.0",
|
||||
"stylelint-scss": "^7.2.0",
|
||||
"typescript": "^6.0.3",
|
||||
"typescript-eslint": "^8.60.1",
|
||||
"vite": "^8.1.5",
|
||||
"vite-plugin-checker": "^0.13.0",
|
||||
"vite-plugin-eslint2": "^5.1.0",
|
||||
"vite-plugin-static-copy": "^4.1.0",
|
||||
"vue": "^3.5.35",
|
||||
"vue-tsc": "^3.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ldc-web/cookie-notice": "^6.0.3",
|
||||
"@sipec/vue3-tags-input": "^3.0.4",
|
||||
"axios": "^1.17.0",
|
||||
"bootstrap": "^5.3.8",
|
||||
"chart.js": "^4.4.0",
|
||||
"cropperjs": "^1.6.1",
|
||||
"eslint": "latest",
|
||||
"eslint-import-resolver-alias": "^1.1.2",
|
||||
"eslint-plugin-vue": "latest",
|
||||
"glightbox": "^3.2.0",
|
||||
"laravel-vite-plugin": "^0.8.1",
|
||||
"meow": "^9.0.0",
|
||||
"postcss-discard-comments": "^6.0.0",
|
||||
"prettier": "latest",
|
||||
"print-js": "^1.6.0",
|
||||
"resolve-url-loader": "^5.0.0",
|
||||
"rollup-plugin-copy": "^3.5.0",
|
||||
"sass": "latest",
|
||||
"scratchcard-js": "^1.5.5",
|
||||
"slugify": "^1.6.6",
|
||||
"stylelint": "^15.11.0",
|
||||
"stylelint-config-idiomatic-order": "github:ream88/stylelint-config-idiomatic-order",
|
||||
"stylelint-config-sass-guidelines": "^10.0.0",
|
||||
"stylelint-config-standard-scss": "^11.1.0",
|
||||
"stylelint-scss": "^5.3.2",
|
||||
"sweetalert2": "^11.7.31",
|
||||
"swiper": "^12.1.3",
|
||||
"terser": "latest",
|
||||
"toastify-js": "^1.12.0",
|
||||
"ts-loader": "^9.3.1",
|
||||
"typescript": ">=3.3.1 <5.2.0",
|
||||
"typescript-eslint": "latest",
|
||||
"vite": "^4.5.1",
|
||||
"vite-plugin-babel": "latest",
|
||||
"vite-plugin-checker": "latest",
|
||||
"vite-plugin-eslint": "latest",
|
||||
"vite-plugin-stylelint": "latest",
|
||||
"vue": "latest",
|
||||
"vue-eslint-parser": "^9.3.2",
|
||||
"vue-loader": "^17.3.1",
|
||||
"vue-tsc": "1.8.11"
|
||||
"toastify-js": "^1.12.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,22 +3,20 @@
|
|||
"sourceMap": true,
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNEXT", "DOM", "DOM.Iterable"],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/*": ["node_modules/*", "node_modules/@types/*"],
|
||||
"@/*": ["resources/assets/*"]
|
||||
"~/*": ["./node_modules/*", "./node_modules/@types/*"],
|
||||
"@/*": ["./resources/assets/*"]
|
||||
},
|
||||
"moduleResolution": "node",
|
||||
"typeRoots": [
|
||||
"resources/ts/@types",
|
||||
"./resources/ts/@types",
|
||||
"resources/theme/mounted/ts/@types",
|
||||
"node_modules/@types"
|
||||
"./node_modules/@types"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"resources/js/**/*.js",
|
||||
"resources/ts/**/*.ts",
|
||||
"resources/ts/**/*.vue"
|
||||
"./resources/js/**/*.js",
|
||||
"./resources/ts/**/*.ts",
|
||||
"./resources/ts/**/*.vue"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
"exclude": ["./node_modules"]
|
||||
}
|
||||
|
|
|
|||
226
vite.config.ts
226
vite.config.ts
|
|
@ -1,81 +1,138 @@
|
|||
import basicSsl from "@vitejs/plugin-basic-ssl";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import autoprefixer from "autoprefixer";
|
||||
import laravel from "laravel-vite-plugin";
|
||||
import path from "path";
|
||||
import path from "node:path";
|
||||
import postcssDiscard from "postcss-discard-comments";
|
||||
import copy from "rollup-plugin-copy";
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import babel from "vite-plugin-babel";
|
||||
import checker from "vite-plugin-checker";
|
||||
import eslint from "vite-plugin-eslint";
|
||||
import stylelint from "vite-plugin-stylelint";
|
||||
import eslint from "vite-plugin-eslint2";
|
||||
import { viteStaticCopy } from "vite-plugin-static-copy";
|
||||
|
||||
const env = loadEnv("r", process.cwd(), "");
|
||||
const isCI = !!process.env.CI;
|
||||
const debugMode = ["local", "development"].includes(process.env.NODE_ENV ?? "");
|
||||
const browserTargets = ["es2019", "edge92", "firefox88", "chrome92", "safari15"];
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
chunkSizeWarningLimit: 1500,
|
||||
target: browserTargets,
|
||||
cssTarget: browserTargets,
|
||||
emptyOutDir: true,
|
||||
sourcemap: debugMode ? "inline" : false,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
entryFileNames: `assets/${
|
||||
process.env.NODE_ENV === "local" ? "[name]-" : ""
|
||||
}[hash].js`,
|
||||
chunkFileNames: `assets/${
|
||||
process.env.NODE_ENV === "local" ? "[name]-" : ""
|
||||
}[hash].js`,
|
||||
entryFileNames: `assets/${debugMode ? "[name]-" : ""}[hash].js`,
|
||||
chunkFileNames: `assets/${debugMode ? "[name]-" : ""}[hash].js`,
|
||||
manualChunks(id) {
|
||||
if (id.includes("node_modules")) {
|
||||
// ! Isole Bootstrap
|
||||
if (id.includes("bootstrap")) return "vendor-bootstrap";
|
||||
// ! Isole Vue
|
||||
if (id.includes("vue")) return "vendor-vue";
|
||||
// ! Isole FontAwesome
|
||||
if (id.includes("@fortawesome")) return "vendor-fontawesome";
|
||||
// ! Isole Ckeditor
|
||||
if (id.includes("ckeditor")) return "vendor-ckeditor";
|
||||
return "vendor";
|
||||
}
|
||||
},
|
||||
assetFileNames: (chunk) => {
|
||||
if (
|
||||
String(chunk.name).endsWith("mail-theme.scss") ||
|
||||
chunk.name === "mail-theme.css"
|
||||
Array.isArray(chunk.names) &&
|
||||
(chunk.names.some(name => String(name).endsWith("mail-theme.scss")) ||
|
||||
chunk.names.includes("mail-theme.css"))
|
||||
) {
|
||||
return "vendor/mail/html/themes/default.[ext]";
|
||||
}
|
||||
return `assets/${process.env.NODE_ENV === "local" ? "[name]-" : ""
|
||||
}[hash].[ext]`;
|
||||
return `assets/${debugMode ? "[name]-" : ""}[hash].[ext]`;
|
||||
},
|
||||
},
|
||||
},
|
||||
emptyOutDir: true,
|
||||
sourcemap: process.env.NODE_ENV === "local" ? "inline" : false,
|
||||
},
|
||||
css: {
|
||||
devSourcemap: debugMode,
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
quietDeps: true
|
||||
}
|
||||
},
|
||||
devSourcemap: process.env.NODE_ENV === "local" ? true : false,
|
||||
postcss: {
|
||||
map: {
|
||||
inline: true,
|
||||
silenceDeprecations: ["color-functions", "global-builtin", "import", "if-function"]
|
||||
},
|
||||
},
|
||||
postcss: {
|
||||
map: { inline: true },
|
||||
plugins: [
|
||||
postcssDiscard({
|
||||
removeAll: true,
|
||||
}),
|
||||
{
|
||||
// Hack pour dégager les code css invalid de cookie notice
|
||||
postcssPlugin: "remove-empty-var",
|
||||
Declaration(decl) {
|
||||
if (decl?.value.includes("var()")) {
|
||||
decl.remove();
|
||||
}
|
||||
}
|
||||
},
|
||||
postcssDiscard({ removeAll: true }),
|
||||
autoprefixer(),
|
||||
],
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
{
|
||||
name: "hmr-symlink-fix",
|
||||
configureServer(server) {
|
||||
// Hack absolu: forcer la détection sur les dossiers ignorés par .gitignore
|
||||
server.watcher.add(path.resolve(process.cwd(), "resources/theme"));
|
||||
server.watcher.add(path.resolve(process.cwd(), "resources/sass"));
|
||||
},
|
||||
handleHotUpdate({ file, server }) {
|
||||
if (file.endsWith(".scss")) {
|
||||
const modulesToUpdate = [];
|
||||
for (const mod of server.moduleGraph.idToModuleMap.values()) {
|
||||
if (!mod.file) continue;
|
||||
|
||||
const isFo = mod.file.endsWith("sass/fo.scss");
|
||||
const isMail = mod.file.endsWith("sass/mail-theme.scss");
|
||||
const isBo = mod.file.endsWith("sass/bo.scss");
|
||||
|
||||
if (isFo || isMail || isBo) {
|
||||
if (file.includes("/resources/theme/") && (isFo || isMail)) {
|
||||
server.moduleGraph.invalidateModule(mod);
|
||||
modulesToUpdate.push(mod);
|
||||
} else if (file.includes("/resources/sass/") && isBo) {
|
||||
server.moduleGraph.invalidateModule(mod);
|
||||
modulesToUpdate.push(mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modulesToUpdate.length > 0) {
|
||||
for (const mod of modulesToUpdate) {
|
||||
server.ws.send({
|
||||
type: "update",
|
||||
updates: [
|
||||
{
|
||||
type: "css-update",
|
||||
path: mod.url,
|
||||
acceptedPath: mod.url,
|
||||
timestamp: Date.now()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
return modulesToUpdate;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
basicSsl(),
|
||||
checker({
|
||||
enableBuild: true,
|
||||
vueTsc: {
|
||||
root: ".",
|
||||
tsconfigPath: "tsconfig.json",
|
||||
},
|
||||
typescript: {
|
||||
root: ".",
|
||||
tsconfigPath: "tsconfig.json",
|
||||
},
|
||||
eslint: {
|
||||
lintCommand:
|
||||
"eslint --quiet -c .eslintrc.json \"./resources/ts/*\" \"./resources/theme/mounted/ts/*\"",
|
||||
},
|
||||
stylelint: {
|
||||
lintCommand:
|
||||
"stylelint --quiet -c .stylelintrc.json --fix ./resources/sass/**/*.scss ./resources/theme/mounted/sass/**/*.scss",
|
||||
},
|
||||
}),
|
||||
...(isCI ? [] : [
|
||||
checker({
|
||||
vueTsc: { root: ".", tsconfigPath: "tsconfig.json" },
|
||||
typescript: { root: ".", tsconfigPath: "tsconfig.json" },
|
||||
stylelint: {
|
||||
lintCommand: "stylelint --quiet -c .stylelintrc.json --fix **/resources/**/*.scss",
|
||||
},
|
||||
})
|
||||
]),
|
||||
laravel({
|
||||
input: [
|
||||
"resources/sass/bo.scss",
|
||||
|
|
@ -84,90 +141,49 @@ export default defineConfig({
|
|||
"resources/theme/mounted/sass/fo.scss",
|
||||
"resources/theme/mounted/ts/fo.ts",
|
||||
],
|
||||
refresh: true,
|
||||
refresh: [
|
||||
"resources/views/**/*.blade.php",
|
||||
"resources/theme/**/views/**/*.blade.php",
|
||||
],
|
||||
}),
|
||||
copy({
|
||||
viteStaticCopy({
|
||||
targets: [
|
||||
{
|
||||
src: [
|
||||
// * Engine copy (Default favicon)
|
||||
path.normalize("resources/favicon/android-chrome-192x192.png"),
|
||||
path.normalize("resources/favicon/android-chrome-512x512.png"),
|
||||
path.normalize("resources/favicon/apple-touch-icon.png"),
|
||||
path.normalize("resources/favicon/browserconfig.xml"),
|
||||
path.normalize("resources/favicon/browserconfig.xml"),
|
||||
path.normalize("resources/favicon/favicon-16x16.png"),
|
||||
path.normalize("resources/favicon/favicon-32x32.png"),
|
||||
path.normalize("resources/favicon/favicon.ico"),
|
||||
path.normalize("resources/favicon/mstile-150x150.png"),
|
||||
path.normalize("resources/favicon/safari-pinned-tab.svg"),
|
||||
path.normalize("resources/favicon/site.webmanifest"),
|
||||
// * Theme Copy (override if present) favicon
|
||||
path.normalize("resources/theme/mounted/favicon/android-chrome-192x192.png"),
|
||||
path.normalize("resources/theme/mounted/favicon/android-chrome-512x512.png"),
|
||||
path.normalize("resources/theme/mounted/favicon/apple-touch-icon.png"),
|
||||
path.normalize("resources/theme/mounted/favicon/browserconfig.xml"),
|
||||
path.normalize("resources/theme/mounted/favicon/browserconfig.xml"),
|
||||
path.normalize("resources/theme/mounted/favicon/favicon-16x16.png"),
|
||||
path.normalize("resources/theme/mounted/favicon/favicon-32x32.png"),
|
||||
path.normalize("resources/theme/mounted/favicon/favicon.ico"),
|
||||
path.normalize("resources/theme/mounted/favicon/mstile-150x150.png"),
|
||||
path.normalize("resources/theme/mounted/favicon/safari-pinned-tab.svg"),
|
||||
path.normalize("resources/theme/mounted/favicon/site.webmanifest"),
|
||||
],
|
||||
dest: path.normalize("public")
|
||||
src: "resources/theme/mounted/favicon/*",
|
||||
dest: "../",
|
||||
rename: { stripBase: true },
|
||||
},
|
||||
{
|
||||
src: "resources/favicon/*",
|
||||
dest: "../",
|
||||
rename: { stripBase: true },
|
||||
overwrite: false,
|
||||
},
|
||||
],
|
||||
copyOnce: true,
|
||||
verbose: true
|
||||
}),
|
||||
stylelint({
|
||||
dev: false,
|
||||
build: true,
|
||||
cache: false,
|
||||
chokidar: true,
|
||||
include: [
|
||||
"**/resources/sass/**/*.scss",
|
||||
"**/resources/sass/**/*.css"
|
||||
],
|
||||
exclude: ["node_modules", "vendor"],
|
||||
lintOnStart: false,
|
||||
emitError: true,
|
||||
emitWarning: true,
|
||||
emitErrorAsWarning: false,
|
||||
emitWarningAsError: true,
|
||||
}),
|
||||
eslint({
|
||||
cache: false,
|
||||
extensions: ["js", "ts"],
|
||||
include: "**/*.ts",
|
||||
exclude: ["node_modules", "vendor"],
|
||||
lintOnStart: false,
|
||||
emitWarning: true,
|
||||
emitError: true,
|
||||
failOnWarning: false,
|
||||
failOnError: false,
|
||||
}),
|
||||
babel({
|
||||
babelConfig: {
|
||||
targets: "last 3 version, not dead, >0.3%"
|
||||
}
|
||||
}),
|
||||
vue({
|
||||
isProduction: process.env.NODE_ENV !== "local" ? true : false,
|
||||
isProduction: !debugMode,
|
||||
exclude: ["node_modules", "vendor"],
|
||||
})
|
||||
],
|
||||
server: {
|
||||
https: true,
|
||||
host: env["APP_URL"] ? new URL(env["APP_URL"]).hostname : "",
|
||||
port: 4443,
|
||||
watch: {
|
||||
usePolling: true,
|
||||
followSymlinks: true,
|
||||
ignored: ["!**/resources/theme/**"]
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
// * This is important for theme
|
||||
preserveSymlinks: true,
|
||||
extensions: ["*", ".js", ".ts", ".vue"],
|
||||
alias: [
|
||||
|
|
@ -185,7 +201,7 @@ export default defineConfig({
|
|||
},
|
||||
{
|
||||
find: "~",
|
||||
replacement: path.resolve(__dirname, "./node_modules"),
|
||||
replacement: path.resolve(process.cwd(), "./node_modules"),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue