mirror of
https://github.com/hanzoai/vite.git
synced 2026-10-30 19:36:16 +00:00
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
const vite = require('vite')
|
|
const workerPluginTestPlugin = require('./worker-plugin-test-plugin')
|
|
|
|
module.exports = vite.defineConfig((sourcemap) => {
|
|
sourcemap = process.env.WORKER_MODE || sourcemap
|
|
if (sourcemap === 'sourcemap') {
|
|
sourcemap = true
|
|
}
|
|
return {
|
|
base: `/iife-${
|
|
typeof sourcemap === 'boolean' ? 'sourcemap' : 'sourcemap-' + sourcemap
|
|
}/`,
|
|
resolve: {
|
|
alias: {
|
|
'@': __dirname,
|
|
},
|
|
},
|
|
worker: {
|
|
format: 'iife',
|
|
plugins: [workerPluginTestPlugin()],
|
|
rollupOptions: {
|
|
output: {
|
|
assetFileNames: 'assets/[name]-worker_asset[hash].[ext]',
|
|
chunkFileNames: 'assets/[name]-worker_chunk[hash].js',
|
|
entryFileNames: 'assets/[name]-worker_entry[hash].js',
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
outDir: `dist/iife-${
|
|
typeof sourcemap === 'boolean' ? 'sourcemap' : 'sourcemap-' + sourcemap
|
|
}/`,
|
|
sourcemap: sourcemap,
|
|
rollupOptions: {
|
|
output: {
|
|
assetFileNames: 'assets/[name]-[hash].[ext]',
|
|
chunkFileNames: 'assets/[name]-[hash].js',
|
|
entryFileNames: 'assets/[name]-[hash].js',
|
|
},
|
|
},
|
|
},
|
|
plugins: [workerPluginTestPlugin()],
|
|
}
|
|
})
|