192 lines
7 KiB
TypeScript
192 lines
7 KiB
TypeScript
import basicSsl from "@vitejs/plugin-basic-ssl";
|
|
import vue from "@vitejs/plugin-vue";
|
|
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 babel from "vite-plugin-babel";
|
|
import checker from "vite-plugin-checker";
|
|
import eslint from "vite-plugin-eslint";
|
|
import stylelint from "vite-plugin-stylelint";
|
|
|
|
const env = loadEnv("r", process.cwd(), "");
|
|
|
|
export default defineConfig({
|
|
build: {
|
|
rollupOptions: {
|
|
output: {
|
|
entryFileNames: `assets/${
|
|
process.env.NODE_ENV === "local" ? "[name]-" : ""
|
|
}[hash].js`,
|
|
chunkFileNames: `assets/${
|
|
process.env.NODE_ENV === "local" ? "[name]-" : ""
|
|
}[hash].js`,
|
|
assetFileNames: (chunk) => {
|
|
if (
|
|
String(chunk.name).endsWith("mail-theme.scss") ||
|
|
chunk.name === "mail-theme.css"
|
|
) {
|
|
return "vendor/mail/html/themes/default.[ext]";
|
|
}
|
|
return `assets/${process.env.NODE_ENV === "local" ? "[name]-" : ""
|
|
}[hash].[ext]`;
|
|
},
|
|
},
|
|
},
|
|
emptyOutDir: true,
|
|
sourcemap: process.env.NODE_ENV === "local" ? "inline" : false,
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
quietDeps: true
|
|
}
|
|
},
|
|
devSourcemap: process.env.NODE_ENV === "local" ? true : false,
|
|
postcss: {
|
|
map: {
|
|
inline: true,
|
|
},
|
|
plugins: [
|
|
postcssDiscard({
|
|
removeAll: true,
|
|
}),
|
|
],
|
|
},
|
|
},
|
|
plugins: [
|
|
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",
|
|
},
|
|
}),
|
|
laravel({
|
|
input: [
|
|
"resources/sass/bo.scss",
|
|
"resources/ts/bo.ts",
|
|
"resources/theme/mounted/sass/mail-theme.scss",
|
|
"resources/theme/mounted/sass/fo.scss",
|
|
"resources/theme/mounted/ts/fo.ts",
|
|
],
|
|
refresh: true,
|
|
}),
|
|
copy({
|
|
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")
|
|
},
|
|
],
|
|
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,
|
|
exclude: ["node_modules", "vendor"],
|
|
})
|
|
],
|
|
server: {
|
|
https: true,
|
|
host: env["APP_URL"] ? new URL(env["APP_URL"]).hostname : "",
|
|
port: 4443,
|
|
watch: {
|
|
usePolling: true,
|
|
},
|
|
},
|
|
resolve: {
|
|
// * This is important for theme
|
|
preserveSymlinks: true,
|
|
extensions: ["*", ".js", ".ts", ".vue"],
|
|
alias: [
|
|
{
|
|
find: "vue",
|
|
replacement: "vue/dist/vue.runtime.esm-bundler.js",
|
|
},
|
|
{
|
|
find: "@",
|
|
replacement: "/resources/assets",
|
|
},
|
|
{
|
|
find: "@Theme",
|
|
replacement: "/resources/theme/mounted/assets",
|
|
},
|
|
{
|
|
find: "~",
|
|
replacement: path.resolve(__dirname, "./node_modules"),
|
|
},
|
|
],
|
|
},
|
|
});
|