generated from b0yblake/Vue-ts-startkit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
91 lines (87 loc) · 2.34 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import ViteComponents from "vite-plugin-components";
import Spritesmith from "vite-plugin-spritesmith";
import { resolve } from "path";
// const isProd = process.env.NODE_ENV === "production";
// const isDevl = process.env.NODE_ENV === "development";
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: [
{
find: "@",
replacement: resolve(__dirname, "/src"),
},
{
find: "~",
replacement: resolve(__dirname, "/src"),
},
// {find: 'views', replacement: resolve(__dirname, 'src/views')},
],
},
css: {
preprocessorOptions: {
scss: {
additionalData: `
@import "./src/assets/stylesheets/_variables";
@import "./src/assets/stylesheets/include-media";
@import "./src/assets/stylesheets/mixins/_mixins.scss";
@import "./src/assets/stylesheets/mixins/_theme.mixin.scss";
@import "./src/assets/stylesheets/sprites-data/sprite.scss";
`,
},
},
},
base: "./", // Set the packaging path
server: {
port: 3000, // Set the service start port number
open: true, // Set whether to automatically open the browser when the service starts
cors: true,
},
plugins: [
vue(),
ViteComponents({
// relative paths to the directory to search for components.
dirs: ["src/components/global"],
// valid file extensions for components.
extensions: ["vue"],
// search for subdirectories
deep: true,
// Allow subdirectories as namespace prefix for components.
directoryAsNamespace: false,
// Subdirectory paths for ignoring namespace prefixes
// works when `directoryAsNamespace: true`
globalNamespaces: [],
}),
Spritesmith({
watch: true,
src: {
cwd: "./src/assets/images/sprites",
glob: "*.png",
},
target: {
image: "./src/assets/stylesheets/sprites-data/sprite.png",
css: [
[
"./src/assets/stylesheets/sprites-data/sprite.scss",
{
format: "handlebars_based_template",
},
],
],
},
apiOptions: {
cssImageRef: "src/assets/stylesheets/sprites-data/sprite.png",
spritesheet_info: {
name: "normal",
format: "handlebars_based_template",
},
},
customTemplates: {
handlebars_based_template:
"./src/assets/stylesheets/sprites-data/spritesmith-mixins.handlebars",
},
}),
],
});