-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsvelte.config.js
96 lines (86 loc) · 2.31 KB
/
svelte.config.js
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
92
93
94
95
96
import path from "path";
import sveltePreprocess from "svelte-preprocess";
import autoprefixer from "autoprefixer";
import postcssPxToRem from "postcss-pxtorem";
const ifDev = process.env.NODE_ENV === "development";
// Deploy your site under a sub path
const basePath = ifDev ? "" : "/test";
// Deploy assets under a CDN or other
const assetsPath = ifDev ? "" : "https://res.ijunhai.com";
const appDir = ifDev ? "_app" : "wechat";
// Design draft
const designDraftWidth = 375;
const remRootValue = 16;
// proxy
const proxyTarget = ifDev
? "http://weixin-huodong.tesn20.com"
: "https://activity.lagbug.com";
const adapter = ({ pages = "build", assets = pages, fallback }) => {
return {
name: "cnguu/svelte-adapter",
async adapt({ utils }) {
utils.rimraf(assets);
utils.rimraf(pages);
utils.copy_static_files(assets);
utils.copy_client_files(assets);
await utils.prerender({
fallback,
all: !fallback,
dest: pages,
});
},
};
};
const config = {
kit: {
target: "#app",
paths: {
base: basePath,
assets: assetsPath,
},
appDir,
adapter: adapter({
pages: "dist",
assets: "dist",
fallback: null,
}),
vite: {
define: {
__BASE_URL__: JSON.stringify(`${basePath}/`),
__DESIGN_DRAFT_WIDTH__: designDraftWidth,
__REM_ROOT_VALUE__: remRootValue,
__PROXY_TARGET__: JSON.stringify(proxyTarget),
},
resolve: {
alias: {
$assets: path.resolve("./src/assets"),
$components: path.resolve("./src/components"),
$configs: path.resolve("./src/configs"),
$directives: path.resolve("./src/directives"),
$plugins: path.resolve("./src/plugins"),
$services: path.resolve("./src/services"),
$styles: path.resolve("./src/styles"),
$utils: path.resolve("./src/utils"),
},
},
},
},
preprocess: sveltePreprocess({
postcss: {
plugins: [
autoprefixer(),
postcssPxToRem({
rootValue: remRootValue,
unitPrecision: 5,
propList: ["*"],
selectorBlackList: [],
replace: true,
mediaQuery: false,
minPixelValue: 0,
exclude: /node_modules/i,
}),
],
},
}),
};
export default config;