|
|
@@ -5,34 +5,9 @@ import vue from '@vitejs/plugin-vue'
|
|
|
import viteCompression from 'vite-plugin-compression'
|
|
|
import eslint from 'vite-plugin-eslint'
|
|
|
import path from 'path'
|
|
|
-import glob from 'glob'
|
|
|
-import fs, {
|
|
|
- fstat
|
|
|
-} from 'fs'
|
|
|
+import fs from 'fs'
|
|
|
const sizeOf = require('image-size')
|
|
|
-// 多页面入口配置
|
|
|
-const entryConfig = function () {
|
|
|
- const viteconfig = {}
|
|
|
- // 含有.js的文件
|
|
|
- const entryFiles = glob.sync('./src/pages/*/*.js')
|
|
|
- // 获取模板
|
|
|
- const temp = fs.readFileSync('./index.html')
|
|
|
- // 模板增加ts入口
|
|
|
- entryFiles.forEach((entry) => {
|
|
|
- const projectName = entry.split('/')[3]
|
|
|
- try {
|
|
|
- fs.accessSync(`./${projectName}.html`)
|
|
|
- } catch (error) {
|
|
|
- // 重构模板
|
|
|
- const html = temp.toString().replace(/\.\/src\/[^\s]*/g, `${entry}"></script>`)
|
|
|
- fs.writeFile(`./${projectName}.html`, html, (err) => {
|
|
|
- if (err) console.error(err)
|
|
|
- })
|
|
|
- }
|
|
|
- viteconfig[projectName] = path.resolve(__dirname, `./${projectName}.html`)
|
|
|
- })
|
|
|
- return viteconfig
|
|
|
-}
|
|
|
+
|
|
|
// 获取CAD图片大小
|
|
|
const getImgSize = function () {
|
|
|
try {
|
|
|
@@ -101,7 +76,9 @@ export default ({
|
|
|
},
|
|
|
build: {
|
|
|
rollupOptions: {
|
|
|
- input: entryConfig(),
|
|
|
+ input:{
|
|
|
+ index: path.resolve(__dirname, 'index.html')
|
|
|
+ },
|
|
|
output: { // 静态资源分类打包
|
|
|
chunkFileNames: 'js/[name]-[hash].js',
|
|
|
entryFileNames: 'js/[name]-[hash].js',
|