docs_vue2/nuxt.config.js

182 lines
3.4 KiB
JavaScript
Raw Normal View History

2020-08-13 11:47:56 +08:00
const path = require('path')
const MonacoEditorPlugin = require('monaco-editor-webpack-plugin')
2020-08-13 11:47:56 +08:00
2022-06-14 09:05:00 +08:00
function resolve(p) {
2020-08-13 11:47:56 +08:00
return path.resolve(__dirname, p)
}
2022-06-14 09:05:00 +08:00
function appendLoader(config, loader) {
2020-08-13 11:47:56 +08:00
config.module.rules.push(loader)
}
module.exports = {
target: 'static',
telemetry: false,
2020-08-13 11:47:56 +08:00
/**
* Headers of the page
*/
head: {
2022-06-14 09:05:00 +08:00
title: '',
2022-05-05 15:52:28 +08:00
htmlAttrs: {
lang: 'zh-Hans'
},
2022-06-14 09:05:00 +08:00
meta: [{
charset: 'utf-8'
},
{
name: 'viewport',
content: 'width=device-width, initial-scale=1'
},
2020-08-13 11:47:56 +08:00
{
hid: 'description',
name: 'description',
2022-06-14 09:05:00 +08:00
content: ''
},
{
name: 'theme-color',
content: '#0052cc'
2020-08-13 11:47:56 +08:00
}
],
2022-06-14 09:05:00 +08:00
// link: [{ rel: 'shortcut icon', href: 'https://www.baidu.com/favicon.ico' }]
2020-08-13 11:47:56 +08:00
},
/**
* Customize the progress bar color
*/
2022-06-14 09:05:00 +08:00
loading: {
color: '#0052cc'
},
2020-08-13 11:47:56 +08:00
pageTransition: {
css: false
},
css: [
'veui-theme-dls/common.less',
'veui-theme-dls/typography.less',
'@/assets/styles/global.styl',
'veui-theme-dls/'
],
2020-08-13 11:47:56 +08:00
2022-06-14 09:05:00 +08:00
plugins: [{
src: '~plugins/global.js'
},
{
src: '~plugins/hm.js',
ssr: false
},
{
src: '~plugins/i18n.js'
},
{
src: '~plugins/l10n.js'
},
{
src: '~plugins/target.js',
ssr: false
},
{
src: '~plugins/prism.js',
ssr: false
}
2020-08-13 11:47:56 +08:00
],
/**
* Build configuration
*/
build: {
2021-12-23 10:12:49 +08:00
cache: true,
parallel: true,
transpile: [
'veui',
'vue-awesome',
'resize-detector',
'less-plugin-dls',
'dls-graphics'
],
2020-08-13 11:47:56 +08:00
babel: {
2021-11-20 13:22:48 +08:00
plugins: ['veui']
2020-08-13 11:47:56 +08:00
},
loaders: {
vue: {
compilerOptions: {
whitespace: 'condense'
}
},
stylus: {
'include css': true
},
less: {
javascriptEnabled: true
}
},
plugins: [
new MonacoEditorPlugin({
languages: ['javascript', 'css', 'html', 'typescript']
})
],
2022-06-14 09:05:00 +08:00
extend(config) {
2020-08-13 11:47:56 +08:00
/**
* veui-loader
*/
appendLoader(config, {
enforce: 'pre',
test: /\.vue$/,
loader: 'veui-loader',
options: {
locale: ['zh-Hans', 'en-US'],
2022-06-14 09:05:00 +08:00
modules: [{
package: 'veui-theme-dls',
fileName: '{module}.js',
transform: false
}]
2020-08-13 11:47:56 +08:00
},
include: [resolve('pages'), resolve('node_modules/veui')]
})
appendLoader(config, {
test: /\.js$/,
include: [resolve('node_modules/focus-visible')],
loader: 'short-circuit-loader',
options: {
expr: "process.env.VUE_ENV === 'server'"
}
})
2021-11-20 13:22:48 +08:00
config.resolve.alias.vue$ = 'vue/dist/vue.esm.js'
config.resolve.alias['vue-monaco'] = '@justfork/vue-monaco'
2021-11-20 13:22:48 +08:00
},
optimization: {
splitChunks: {
cacheGroups: {
veui: {
test: /node_modules[\\/]veui/,
chunks: 'all',
priority: 20,
name: true
},
'veui-theme-dls-icons': {
test: /node_modules[\\/]veui-theme-dls-icons/,
chunks: 'all',
priority: 20,
name: true
},
'vue-live': {
test: /node_modules[\\/]vue-live/,
chunks: 'all',
priority: 20,
name: true
}
}
}
2020-08-13 11:47:56 +08:00
}
}
}