generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
61 lines (56 loc) · 1.82 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
import { defineConfig } from 'vite';
import minifyHTML from 'rollup-plugin-minify-html-literals';
import { generateBlockEntries, generateIconNameType } from './vite.helpers';
import { config } from './config.ts';
import { resolve } from 'path';
import { InputOption } from 'rollup';
const isProd = process.env.NODE_ENV === 'production';
// @ts-ignore:next line
export default defineConfig(({ command, mode }) => {
const { mainTsPath, mainScssPath, fontsScssPath, lazyStylesScssPath, sidekickLibraryStylesScssPath } = config;
const blocksEntries = generateBlockEntries();
generateIconNameType();
const inputOptions: InputOption = {
main: resolve(__dirname, mainTsPath),
styles: resolve(__dirname, mainScssPath),
...blocksEntries,
};
if (fontsScssPath) inputOptions.fonts = resolve(__dirname, fontsScssPath);
if (lazyStylesScssPath) inputOptions.lazyStyles = resolve(__dirname, lazyStylesScssPath);
if (sidekickLibraryStylesScssPath) {
inputOptions.sidekickLibraryStyles = resolve(__dirname, sidekickLibraryStylesScssPath);
}
return {
css: {
devSourcemap: true,
preprocessorOptions: {
scss: {
additionalData: `@import 'src/styles/sass/libs/_index.scss';`,
},
},
},
build: {
sourcemap: true,
minify: true,
cssMinify: true,
commonjsOptions: {
include: ['node_modules/**'],
},
emptyOutDir: true,
rollupOptions: {
cache: false,
preserveEntrySignatures: 'strict',
input: inputOptions,
output: {
dir: 'dist',
assetFileNames: () => {
return '[name]/[name][extname]';
},
chunkFileNames: '__chunks__/[name].[hash].js',
entryFileNames: '[name]/[name].js',
},
plugins: [isProd && minifyHTML()],
},
},
};
});