|
1 | 1 | import * as fs from 'node:fs'; |
2 | 2 | import * as path from 'node:path'; |
3 | | -import { defineConfig, type RolldownOptions } from 'rolldown'; |
| 3 | +import { defineConfig } from 'rolldown'; |
4 | 4 |
|
5 | | -const isDev = !process.argv.includes('--minify'); |
6 | | -const resolve = (...paths: string[]) => path.resolve(__dirname, ...paths); |
7 | | - |
8 | | -const config: RolldownOptions = { |
| 5 | +export default defineConfig({ |
9 | 6 | input: { |
10 | | - 'extension': './index.ts', |
11 | | - 'reactivity-analysis-plugin': './lib/reactivityAnalysisPlugin.ts', |
| 7 | + 'extension': './src/extension.ts', |
| 8 | + 'reactivity-analysis-plugin': './src/reactivityAnalysisPlugin.ts', |
| 9 | + 'language-server': './node_modules/@vue/language-server/index.ts', |
| 10 | + 'typescript-plugin': './node_modules/@vue/typescript-plugin/index.ts', |
12 | 11 | }, |
13 | 12 | output: { |
14 | 13 | format: 'cjs', |
15 | | - sourcemap: isDev, |
| 14 | + minify: true, |
| 15 | + }, |
| 16 | + transform: { |
| 17 | + define: { |
| 18 | + 'process.env.NODE_ENV': '"production"', |
| 19 | + }, |
16 | 20 | }, |
17 | | - define: { |
18 | | - 'process.env.NODE_ENV': '"production"', |
| 21 | + checks: { |
| 22 | + eval: false, |
19 | 23 | }, |
20 | 24 | external: ['vscode'], |
21 | 25 | plugins: [ |
22 | 26 | { |
23 | 27 | name: 'clean', |
24 | 28 | buildStart() { |
25 | | - fs.rmSync(resolve('./dist'), { recursive: true, force: true }); |
26 | | - }, |
27 | | - }, |
28 | | - { |
29 | | - name: 'redirect', |
30 | | - buildEnd() { |
31 | | - fs.mkdirSync(resolve('./node_modules/vue-typescript-plugin-pack'), { recursive: true }); |
32 | | - fs.writeFileSync( |
33 | | - resolve('./node_modules/vue-typescript-plugin-pack/index.js'), |
34 | | - `module.exports = require('../../dist/typescript-plugin.js');`, |
35 | | - ); |
36 | | - |
37 | | - fs.mkdirSync(resolve('./node_modules/vue-reactivity-analysis-plugin-pack'), { recursive: true }); |
38 | | - fs.writeFileSync( |
39 | | - resolve('./node_modules/vue-reactivity-analysis-plugin-pack/index.js'), |
40 | | - `module.exports = require('../../dist/reactivity-analysis-plugin.js');`, |
41 | | - ); |
42 | | - |
43 | | - if (isDev) { |
44 | | - fs.mkdirSync(resolve('./dist'), { recursive: true }); |
45 | | - fs.writeFileSync( |
46 | | - resolve('./dist/language-server.js'), |
47 | | - `module.exports = require('../node_modules/@vue/language-server/index.js');`, |
48 | | - ); |
49 | | - fs.writeFileSync( |
50 | | - resolve('./dist/typescript-plugin.js'), |
51 | | - `module.exports = require('../node_modules/@vue/typescript-plugin/index.js');`, |
52 | | - ); |
53 | | - } |
| 29 | + fs.rmSync(path.resolve(__dirname, './dist'), { recursive: true, force: true }); |
54 | 30 | }, |
55 | 31 | }, |
56 | 32 | { |
@@ -79,14 +55,4 @@ const config: RolldownOptions = { |
79 | 55 | }, |
80 | 56 | }, |
81 | 57 | ], |
82 | | -}; |
83 | | - |
84 | | -if (!isDev) { |
85 | | - config.input = { |
86 | | - ...config.input as Record<string, string>, |
87 | | - 'language-server': './node_modules/@vue/language-server/index.js', |
88 | | - 'typescript-plugin': './node_modules/@vue/typescript-plugin/index.js', |
89 | | - }; |
90 | | -} |
91 | | - |
92 | | -export default defineConfig(config); |
| 58 | +}); |
0 commit comments