naive-ui/vite.config.js

66 lines
1.7 KiB
JavaScript
Raw Normal View History

const path = require('path')
const { babel } = require('@rollup/plugin-babel')
const rollupCssRenderPlugin = require('./build/rollup-plugin-css-render')
const rollupDemoPlugin = require('./build/rollup-plugin-demo')
const viteCssRenderPlugin = require('./build/vite-plugin-css-render')
const viteDemoPlugin = require('./build/vite-plugin-demo')
module.exports = {
root: __dirname,
2020-11-02 15:40:23 +08:00
plugins: [
viteDemoPlugin(),
viteCssRenderPlugin()
2020-11-02 15:40:23 +08:00
],
2020-11-05 15:36:27 +08:00
outDir: 'site',
optimizeDeps: {
2020-11-01 19:35:00 +08:00
include: [
'highlight.js/lib/core',
2020-11-01 19:35:00 +08:00
'highlight.js/lib/languages/cpp',
'highlight.js/lib/languages/javascript',
2020-12-04 19:40:17 +08:00
'highlight.js/lib/languages/python'
2020-11-01 19:35:00 +08:00
]
},
alias: {
'/@naive-ui/': path.resolve(__dirname, './src'),
2020-11-03 11:53:37 +08:00
src: path.resolve(__dirname, './src')
},
define: {
'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
2020-11-03 11:53:37 +08:00
__DEV__: process.env.NODE_ENV !== 'production'
},
2020-12-07 21:44:41 +08:00
minify: false,
2020-11-02 15:40:23 +08:00
rollupPluginVueOptions: {
include: /\.(vue|md|demo.md|demo-entry.md|entry)$/
},
rollupInputOptions: {
plugins: [
rollupDemoPlugin(),
rollupCssRenderPlugin(),
babel({
2020-12-07 16:26:33 +08:00
babelHelpers: 'bundled'
// exclude: 'node_modules/highlight.js/**'
})
]
2020-11-02 21:41:40 +08:00
},
indexHtmlTransforms: [
{
apply: 'pre',
transform ({ code }) {
2020-11-11 20:48:42 +08:00
const isTusimple = !!process.env.TUSIMPLE
2020-11-02 21:41:40 +08:00
switch (process.env.NODE_ENV) {
case 'production':
2020-11-11 20:48:42 +08:00
return code.replace(
/__INDEX__/,
'/demo/index.' + (isTusimple ? 'ts-prod.js' : 'prod.js')
)
2020-11-02 21:41:40 +08:00
default:
2020-11-11 20:48:42 +08:00
return code.replace(
/__INDEX__/,
'/demo/index.' + (isTusimple ? 'ts-dev.js' : 'dev.js')
)
2020-11-02 21:41:40 +08:00
}
}
}
]
}