修复http-server预览指令报错的问题,vite相关相关插件配置优化

This commit is contained in:
hooray
2021-09-20 07:28:10 +08:00
parent 93bad49662
commit ba74283b8a
5 changed files with 29 additions and 7 deletions
+1
View File
@@ -83,6 +83,7 @@
margin-top: 20px;
}
</style>
<%- copyrightScript %>
<% if (appMode == 'example') { %>
<script>
var _hmt = _hmt || [];
+3 -3
View File
@@ -6,9 +6,9 @@
"build:test": "vite build --mode test",
"build": "vite build",
"build:example": "vite build --mode example",
"serve:test": "hs ./dist-test -o",
"serve": "hs ./dist -o",
"serve:example": "hs ./dist-example -o",
"serve:test": "http-server ./dist-test -o",
"serve": "http-server ./dist -o",
"serve:example": "http-server ./dist-example -o",
"svgo": "svgo -f src/assets/icons",
"new": "plop",
"lint:eslint": "eslint src/**/*.{js,vue} --fix",
+4 -2
View File
@@ -3,8 +3,10 @@ import banner from 'vite-plugin-banner'
export default function createBanner() {
return banner(`
/**
* name: Fantastic-admin
* homepage: https://hooray.gitee.io/fantastic-admin/
* 由 Fantastic-admin 提供技术支持
* https://hooray.gitee.io/fantastic-admin/
* Powered by Fantastic-admin
* https://hooray.github.io/fantastic-admin/
*/
`)
}
+11 -1
View File
@@ -1,5 +1,9 @@
import htmlPlugin from 'vite-plugin-html'
const copyright_common_style = 'font-size: 14px; margin-bottom: 2px; padding: 6px 8px; color: #fff;'
const copyright_main_style = `${copyright_common_style} background: #e24329;`
const copyright_sub_style = `${copyright_common_style} background: #707070;`
export default function createHtml(env, isBuild) {
const { VITE_APP_TITLE, VITE_APP_DEBUG_TOOL, VITE_APP_MODE } = env
const html = htmlPlugin({
@@ -7,7 +11,13 @@ export default function createHtml(env, isBuild) {
injectData: {
title: VITE_APP_TITLE,
debugTool: VITE_APP_DEBUG_TOOL,
appMode: VITE_APP_MODE
appMode: VITE_APP_MODE,
copyrightScript: `
<script>
console.info('%c由%cFantastic-admin%c提供技术支持', '${copyright_sub_style}', '${copyright_main_style}', '${copyright_sub_style}', '\\nhttps://hooray.gitee.io/fantastic-admin/');
console.info('%cPowered by%cFantastic-admin', '${copyright_sub_style}', '${copyright_main_style}', '\\nhttps://hooray.github.io/fantastic-admin/');
</script>
`
}
},
minify: isBuild
+10 -1
View File
@@ -4,7 +4,16 @@ export default function createRestart() {
return ViteRestart({
restart: [
'.env.development',
'vite/plugins/index.js'
'vite/plugins/index.js',
'vite/plugins/auto-import.js',
'vite/plugins/banner.js',
'vite/plugins/components.js',
'vite/plugins/compression.js',
'vite/plugins/html.js',
'vite/plugins/mock.js',
'vite/plugins/restart.js',
'vite/plugins/spritesmith.js',
'vite/plugins/svg-icon.js'
]
})
}