-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.mjs
56 lines (51 loc) · 1.39 KB
/
vite.config.mjs
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
import FastGlob from 'fast-glob';
import FullReload from 'vite-plugin-full-reload'
import { resolve } from 'node:path';
// Create an array of all the top level JS and SCSS files in the js and sass
// directories.
const inputFiles = FastGlob.sync('(js|sass)/*.(scss|js)', {
// Ignore Sass partials and the jQuery module.
ignore: [
'sass/_*.scss',
'js/jquery.module.js',
]
}).map(file => {
// This expands the relative paths to absolute paths, so e.g.
// src/nested/foo becomes /project/src/nested/foo.js
return resolve(process.cwd(), file)
})
export default {
plugins: [
// Watch the PHP files for changes and reload the browser.
FullReload(process.cwd() + '/**/*.(php|inc|theme|twig)')
],
css: {
preprocessorOptions: {
scss: {
// Use the modern SCSS compiler.
api: 'modern',
},
},
},
build: {
// generate manifest.json in outDir
manifest: true,
// minify: false,
rollupOptions: {
// overwrite default .html entry
input: inputFiles,
// Remove the [hash] since Drupal will take care of that.
output: {
entryFileNames: `[name].js`,
chunkFileNames: `chunks/[name].[hash].js`,
assetFileNames: `[name].[ext]`,
}
}
},
// Swap any npm jQuery import for the custom local module.
resolve: {
alias: {
jquery: resolve(process.cwd(), 'js/jquery.module.js'),
},
},
}