Kaynağa Gözat

修复程序打包bug。

yangzhijie 4 yıl önce
ebeveyn
işleme
583e19c8a1
6 değiştirilmiş dosya ile 7810 ekleme ve 20 silme
  1. 7761 1
      package-lock.json
  2. 2 2
      package.json
  3. 0 0
      src/assets/summernote.css
  4. 0 3
      vue.config.js
  5. 13 6
      webpack.base.js
  6. 34 8
      webpack.prod.js

Dosya farkı çok büyük olduğundan ihmal edildi
+ 7761 - 1
package-lock.json


+ 2 - 2
package.json

@@ -6,10 +6,10 @@
   "private": true,
   "scripts": {
     "dev": "webpack serve --config ./webpack.dev.js",
-    "build": "webpack --mode=production --config ./webpack.prod.cjs --progress --hide-modules"
+    "build": "cross-env NODE_ENV=production webpack --mode=production --config ./webpack.prod.js --progress"
   },
   "dependencies": {
-    "pc-component-v3": "^1.0.17",
+    "pc-component-v3": "^1.0.19",
 	  "@riophae/vue-treeselect": "^0.4.0",
     "ant-design-vue": "^3.0.0-beta.6",    
 	  "v-tooltip": "^4.0.0-beta.17",

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
src/assets/summernote.css


+ 0 - 3
vue.config.js

@@ -1,3 +0,0 @@
-module.exports = {
-    lintOnSave: false,    
-}

+ 13 - 6
webpack.base.js

@@ -2,6 +2,7 @@ var path = require('path')
 var webpack = require('webpack')
 const { VueLoaderPlugin } = require('vue-loader')
 const ESLintPlugin = require('eslint-webpack-plugin');
+const MiniCssExtractPlugin = require('mini-css-extract-plugin');
 
 module.exports = {
   module: {
@@ -33,17 +34,23 @@ module.exports = {
             'css-loader'] : ['style-loader', 'css-loader']
         },
         {
+          // webpack5 通过资源模块来处理图片
           test: /\.(png|jpg|gif|svg)$/,
-          loader: 'file-loader',
-          options: {
-            name: './image/[name].[ext]?[hash]'
+          type: 'asset',
+          parser: {
+            dataUrlCondition: {
+                maxSize: 10240
+            }
+          },
+          generator: {
+            filename: './asset-image/[name][ext][query]'
           }
         },
         {
           test: /\.(eot|woff|woff2|ttf)$/,
-          loader: 'file-loader',
-          options: {
-            name: './font/[name].[ext]?[hash]'
+          type:"asset/resource",
+          generator:{
+            filename:"./asset-font/[name].[hash:6][ext]"
           }
         },
         {

+ 34 - 8
webpack.prod.js

@@ -4,6 +4,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
 const HtmlWebpackPlugin = require('html-webpack-plugin');
 const WebpackMerge = require('webpack-merge')
 const baseConfig = require('./webpack.base.js')
+const { name } = require('./package');
 
 module.exports =  WebpackMerge.merge(baseConfig, {
   mode: 'production',
@@ -17,23 +18,48 @@ module.exports =  WebpackMerge.merge(baseConfig, {
     main: './src/main.js',
   },
 
+
   output: {
-    path: path.resolve(__dirname, '../dist/dist/app'),
-    publicPath: './dist/app/',
-    filename: 'js/[name].[contenthash:8].js',
-    chunkFilename: 'js/[name].[contenthash:8].js',
+    path: path.resolve(__dirname, './dist/client-trace-v3'),
+    publicPath: './',
+    library: `${name}`,
+    libraryTarget: 'umd', // 把微应用打包成 umd 库格式
+    filename: './asset-js-bundle/[name].[contenthash:8].js',
+    chunkFilename: './asset-js-chunk/[name].[contenthash:8].js',
+  },
+
+
+  
+  optimization: {
+    minimize: true,    // 压缩 bundle
+    splitChunks: {
+      // include all types of chunks
+      chunks: 'all',
+      // name: false,
+      minSize: 30000,
+      maxSize: 500000,
+      cacheGroups: {
+        common: {
+          test: /[\\/]node_modules[\\/]/,
+          name: 'common',
+          chunks: 'initial',
+          priority: 2,
+          minChunks: 2,
+        },
+      }
+    },
   },
 
+  //devtool: 'nosources-source-map', // 打包不需要 source-map
 
-  devtool: 'source-map',
 
   plugins: (module.exports.plugins || []).concat([
 
 
     new HtmlWebpackPlugin({
       title: 'Prodog',
-      template: './static/htmls/template.html',  // 源模板文件
-      filename: (process.env.NODE_ENV === 'production') ? '../../index.html' : './index.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
+      template: './public/index.html',  // 源模板文件
+      filename: './index.html', // 输出文件【注意:这里的根路径是module.exports.output.path】
       chunks: ['main']
     }),
 
@@ -43,7 +69,7 @@ module.exports =  WebpackMerge.merge(baseConfig, {
 
     // CSS 提取
     new MiniCssExtractPlugin({
-      filename: "style/[name].[contenthash:8].css"
+      filename: "./asset-style/[name].[contenthash:8].css"
     }),
 
   ])

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor