-
Notifications
You must be signed in to change notification settings - Fork 902
Expand file tree
/
Copy pathvite.config.js
More file actions
55 lines (50 loc) · 1.57 KB
/
Copy pathvite.config.js
File metadata and controls
55 lines (50 loc) · 1.57 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const path = require('path');
const concatScripts = require('./vite-plugins/concat-scripts');
const htmlInclude = require('./vite-plugins/html-include');
const cssReplace = require('./vite-plugins/css-replace');
const VIRTUAL_ENTRY = 'virtual:piskel-entry';
const RESOLVED_ENTRY = '\0' + VIRTUAL_ENTRY;
/**
* Minimal entry plugin. Vite/Rollup requires at least one entry point,
* but all real work is done by our concat/html/css plugins.
* This just provides a no-op entry so Rollup doesn't error.
*/
function virtualEntry() {
return {
name: 'piskel-virtual-entry',
resolveId(id) {
if (id === VIRTUAL_ENTRY) return RESOLVED_ENTRY;
return null;
},
load(id) {
if (id === RESOLVED_ENTRY) return '// piskel build entry';
return null;
},
};
}
/** @type {import('vite').UserConfig} */
module.exports = {
plugins: [
virtualEntry(),
htmlInclude({ rootDir: __dirname }),
concatScripts({ rootDir: __dirname }),
cssReplace(),
],
build: {
outDir: path.resolve(__dirname, 'dest/prod'),
emptyOutDir: true,
rollupOptions: {
input: VIRTUAL_ENTRY,
output: {
// The virtual entry produces a trivial JS file; we'll clean it up
entryFileNames: '_entry.js',
},
},
// We handle minification ourselves via terser in the concat plugin
minify: false,
// Disable CSS processing - we concatenate manually
cssCodeSplit: false,
},
// Dev server and preview are handled by scripts/dev-server.js
// (Vite's dev server assumes ES modules which doesn't fit our concat-based debug mode)
};