caner 2 years ago
parent
commit
d52b33ffae
4 changed files with 6 additions and 29 deletions
  1. BIN
      .DS_Store
  2. 1 1
      index.html
  3. BIN
      public/.DS_Store
  4. 5 28
      vite.config.js

BIN
.DS_Store


+ 1 - 1
index.html

@@ -10,7 +10,7 @@
 
 
 <body>
 <body>
   <div id="app"></div>
   <div id="app"></div>
-  <script type="module" src="./src/pages/index/main.js"></script>
+  <script type="module" src="./src/pages/main.js"></script>
 </body>
 </body>
 
 
 </html>
 </html>

BIN
public/.DS_Store


+ 5 - 28
vite.config.js

@@ -5,34 +5,9 @@ import vue from '@vitejs/plugin-vue'
 import viteCompression from 'vite-plugin-compression'
 import viteCompression from 'vite-plugin-compression'
 import eslint from 'vite-plugin-eslint'
 import eslint from 'vite-plugin-eslint'
 import path from 'path'
 import path from 'path'
-import glob from 'glob'
-import fs, {
-  fstat
-} from 'fs'
+import fs from 'fs'
 const sizeOf = require('image-size')
 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图片大小
 // 获取CAD图片大小
 const getImgSize = function () {
 const getImgSize = function () {
   try {
   try {
@@ -101,7 +76,9 @@ export default ({
   },
   },
   build: {
   build: {
     rollupOptions: {
     rollupOptions: {
-      input: entryConfig(),
+      input:{
+        index: path.resolve(__dirname, 'index.html')
+      },
       output: { // 静态资源分类打包
       output: { // 静态资源分类打包
         chunkFileNames: 'js/[name]-[hash].js',
         chunkFileNames: 'js/[name]-[hash].js',
         entryFileNames: 'js/[name]-[hash].js',
         entryFileNames: 'js/[name]-[hash].js',