-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
38 lines (35 loc) · 1.07 KB
/
vite.config.ts
File metadata and controls
38 lines (35 loc) · 1.07 KB
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
import path from "path";
import { Plugin, defineConfig } from "vite";
function LitCSSLoader(): Plugin {
return {
name: "vite-css-plg",
transform: function (code: string, id: string) {
if (id.endsWith(".css")) {
return `import {css} from 'lit'; console.log('cssloader!!');export const style = css\`${code}\`\n;export default style`;
}
return code;
}
};
}
// https://vitejs.dev/config/
export default (opts: any) => {
let development = process.env.NODE_ENV != "production";
return defineConfig({
server: {
port: 3080,
host: "0.0.0.0"
},
resolve: {
conditions: ["dev"],
alias: [
// Subpaths importing compiled names with ".js" -> map to source ".ts"
{ find: /^@conectate\/components\/(.+)\.js$/, replacement: path.resolve(__dirname, "src") + "/$1.ts" },
// Subpaths importing without extension -> map to source ".ts"
{ find: /^@conectate\/components\/(.+)$/, replacement: path.resolve(__dirname, "src") + "/$1.ts" }
]
},
define: {
"process.env.NODE_ENV": JSON.stringify(development ? "development" : "production")
}
});
};