mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-03-25 14:10:50 +08:00
site: vite build, not error (wip)
This commit is contained in:
parent
ec30de44a1
commit
899b29c48c
@ -8,8 +8,10 @@
|
||||
<script>
|
||||
import zhCN from './zhCN/index'
|
||||
import enUS from './enUS/index'
|
||||
|
||||
zhCN.name = 'zh-CN'
|
||||
enUS.name = 'en-US'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
'en-US': enUS,
|
||||
|
@ -2,6 +2,17 @@ const path = require('path')
|
||||
const fs = require('fs')
|
||||
const template = fs.readFileSync(path.join(__dirname, 'ComponentDocumentationEntryTemplate.vue')).toString()
|
||||
|
||||
// user may use different index for a locale
|
||||
// for example
|
||||
// enUS/index.md
|
||||
// zhCN/index.md
|
||||
//
|
||||
// enUS/index.demo-entry.md
|
||||
// zhCN/index.demo-entry.md
|
||||
//
|
||||
// enUS/index.vue
|
||||
// zhCN/index.vue
|
||||
|
||||
module.exports = (entryPath) => {
|
||||
let resultTemplate = template
|
||||
const replaceReg = /index/g
|
||||
|
@ -95,6 +95,8 @@ function genVueComponent (parts, fileName, relativeUrl, noRunning = false) {
|
||||
}
|
||||
if (parts.script && !noRunning) {
|
||||
src = src.replace(scriptReg, parts.script)
|
||||
} else {
|
||||
src = src.replace(scriptReg, 'export default {}')
|
||||
}
|
||||
if (parts.style) {
|
||||
src = src.replace(styleReg, parts.style)
|
||||
|
@ -42,18 +42,19 @@ module.exports = {
|
||||
},
|
||||
rollupMdPlugin: function () {
|
||||
return {
|
||||
async transform (code, id) {
|
||||
console.log('id', id)
|
||||
async load (id) {
|
||||
if (id.endsWith('.demo.md')) {
|
||||
const code = readFileSync(id).toString()
|
||||
return NaiveUIDemoLoader(code, id)
|
||||
} else if (id.endsWith('.demo-entry.md')) {
|
||||
return NaiveUIDocEntryLoader(id)
|
||||
} else if (id.endsWith('.entry')) {
|
||||
NaiveUIDocLoader(code, id)
|
||||
return NaiveUIDocEntryLoader(id)
|
||||
} else if (id.endsWith('.demo-entry.md')) {
|
||||
const code = readFileSync(id).toString()
|
||||
return NaiveUIDocLoader(code, id)
|
||||
} else if (id.endsWith('.md')) {
|
||||
const code = readFileSync(id).toString()
|
||||
return NaiveUIMdLoader(code, id)
|
||||
}
|
||||
return code
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,7 @@ module.exports = {
|
||||
nodeResolve({
|
||||
extensions: ['.js', '.json', '.vue']
|
||||
}),
|
||||
vuePlugin({
|
||||
compilerOptions: {
|
||||
whitespace: 'condense'
|
||||
}
|
||||
}),
|
||||
vuePlugin(),
|
||||
terser({
|
||||
mangle: false,
|
||||
output: {
|
||||
|
@ -5,7 +5,9 @@ const { viteMdPlugin, rollupMdPlugin } = require('./demo/vite-plugins/mdPlugin')
|
||||
|
||||
module.exports = {
|
||||
root: __dirname,
|
||||
plugins: [ viteMdPlugin() ],
|
||||
plugins: [
|
||||
viteMdPlugin()
|
||||
],
|
||||
optimizeDeps: {
|
||||
include: [
|
||||
'highlight.js/lib/languages/cpp',
|
||||
@ -24,6 +26,9 @@ module.exports = {
|
||||
'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
|
||||
'__DEV__': process.env !== 'production'
|
||||
},
|
||||
rollupPluginVueOptions: {
|
||||
include: /\.(vue|md|demo.md|demo-entry.md|entry)$/
|
||||
},
|
||||
rollupInputOptions: {
|
||||
plugins: [
|
||||
alias({
|
||||
@ -31,6 +36,10 @@ module.exports = {
|
||||
{
|
||||
find: /^naive-ui\/lib\/icons\//g,
|
||||
replacement: './src/_deprecated/icons/'
|
||||
},
|
||||
{
|
||||
find: /^naive-ui$/g,
|
||||
replacement: './src/index.js'
|
||||
}
|
||||
]
|
||||
}),
|
||||
|
Loading…
x
Reference in New Issue
Block a user