2020-09-29 15:03:46 +08:00
|
|
|
const path = require('path')
|
2020-12-04 18:12:24 +08:00
|
|
|
const { babel } = require('@rollup/plugin-babel')
|
2020-11-12 13:30:04 +08:00
|
|
|
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')
|
2020-10-26 15:03:02 +08:00
|
|
|
|
2020-09-29 15:03:46 +08:00
|
|
|
module.exports = {
|
|
|
|
root: __dirname,
|
2020-11-02 15:40:23 +08:00
|
|
|
plugins: [
|
2020-11-12 13:30:04 +08:00
|
|
|
viteDemoPlugin(),
|
|
|
|
viteCssRenderPlugin()
|
2020-11-02 15:40:23 +08:00
|
|
|
],
|
2020-11-05 15:36:27 +08:00
|
|
|
outDir: 'site',
|
2020-10-26 15:03:02 +08:00
|
|
|
optimizeDeps: {
|
2020-11-01 19:35:00 +08:00
|
|
|
include: [
|
2020-12-04 18:12:24 +08:00
|
|
|
'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
|
|
|
]
|
2020-10-26 15:03:02 +08:00
|
|
|
},
|
2020-09-29 15:03:46 +08:00
|
|
|
alias: {
|
2020-10-26 15:03:02 +08:00
|
|
|
'/@naive-ui/': path.resolve(__dirname, './src'),
|
2020-11-03 11:53:37 +08:00
|
|
|
src: path.resolve(__dirname, './src')
|
2020-09-29 15:03:46 +08:00
|
|
|
},
|
|
|
|
define: {
|
|
|
|
'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
|
2020-11-03 11:53:37 +08:00
|
|
|
__DEV__: process.env.NODE_ENV !== 'production'
|
2020-11-02 04:23:28 +08:00
|
|
|
},
|
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)$/
|
|
|
|
},
|
2020-11-02 04:23:28 +08:00
|
|
|
rollupInputOptions: {
|
|
|
|
plugins: [
|
2020-11-12 13:30:04 +08:00
|
|
|
rollupDemoPlugin(),
|
2020-12-04 18:12:24 +08:00
|
|
|
rollupCssRenderPlugin(),
|
|
|
|
babel({
|
2020-12-07 16:26:33 +08:00
|
|
|
babelHelpers: 'bundled'
|
|
|
|
// exclude: 'node_modules/highlight.js/**'
|
2020-12-04 18:12:24 +08:00
|
|
|
})
|
2020-11-02 04:23:28 +08:00
|
|
|
]
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2020-09-29 15:03:46 +08:00
|
|
|
}
|