瀏覽代碼

🚀 feat: add imageCompression

chuzhixin 2 年之前
父節點
當前提交
349e4c8902
共有 5 個文件被更改,包括 20 次插入19 次删除
  1. 2 2
      README.en.md
  2. 3 3
      README.md
  3. 3 6
      package.json
  4. 2 0
      src/config/setting.config.js
  5. 10 8
      vue.config.js

+ 2 - 2
README.en.md

@@ -59,7 +59,7 @@
 
 ```bash
 git clone -b vue3.0-antdv https://github.com/chuzhixin/vue-admin-better.git
-npm i
+npm i --registry=http://mirrors.cloud.tencent.com/npm/
 npm run serve
 ```
 
@@ -67,7 +67,7 @@ npm run serve
 
 ```bash
 git clone -b master https://github.com/chuzhixin/vue-admin-better.git
-npm i
+npm i --registry=http://mirrors.cloud.tencent.com/npm/
 npm run serve
 ```
 

+ 3 - 3
README.md

@@ -80,7 +80,7 @@
 # 克隆项目
 git clone -b vue3.0-antdv https://github.com/chuzhixin/vue-admin-better.git
 # 安装依赖
-npm i
+npm i --registry=http://mirrors.cloud.tencent.com/npm/
 # 本地开发 启动项目
 npm run serve
 ```
@@ -91,7 +91,7 @@ npm run serve
 # 克隆项目
 git clone  https://github.com/chuzhixin/vue-admin-arco.git
 # 安装依赖
-npm i
+npm i --registry=http://mirrors.cloud.tencent.com/npm/
 # 本地开发 启动项目
 npm run dev
 ```
@@ -102,7 +102,7 @@ npm run dev
 # 克隆项目
 git clone -b master https://github.com/chuzhixin/vue-admin-better.git
 # 安装依赖
-npm i
+npm i --registry=http://mirrors.cloud.tencent.com/npm/
 # 本地开发 启动项目
 npm run serve
 ```

+ 3 - 6
package.json

@@ -11,16 +11,13 @@
     "serve": "vue-cli-service serve",
     "build": "vue-cli-service build",
     "build:report": "vue-cli-service build --report",
-    "globle": "npm install -g cnpm --registry=https://registry.npmmirror.com&&cnpm i rimraf npm-check-updates nrm -g&&rimraf node_modules&&cnpm i",
+    "globle": "npm install -g cnpm  --registry=http://mirrors.cloud.tencent.com/npm/&&cnpm i rimraf npm-check-updates nrm -g&&rimraf node_modules&&cnpm i",
     "lint": "vue-cli-service lint",
     "lint:style": "stylelint-config-prettier-check",
     "inspect": "vue-cli-service inspect",
-    "template": "plop",
-    "clear": "rimraf node_modules&&npm install --registry=https://registry.npmmirror.com",
+    "clear": "rimraf node_modules&&npm install  --registry=http://mirrors.cloud.tencent.com/npm/",
     "image-webpack-loader": "cnpm i image-webpack-loader -D",
-    "use:npm": "nrm use npm",
-    "use:taobao": "nrm use taobao",
-    "update": "ncu -u --reject sass-loader,sass,screenfull,eslint,chalk,vue-echarts,vue,vue-template-compiler,vue-router,vuex,@vue/cli-plugin-babel,@vue/cli-plugin-eslint,@vue/cli-service,eslint-plugin-vue --registry https://registry.npmmirror.com&&cnpm i",
+    "update": "ncu -u --reject sass-loader,sass,screenfull,eslint,chalk,vue-echarts,vue,vue-template-compiler,vue-router,vuex,@vue/cli-plugin-babel,@vue/cli-plugin-eslint,@vue/cli-service,eslint-plugin-vue --registry=http://mirrors.cloud.tencent.com/npm/&&npm i --registry=http://mirrors.cloud.tencent.com/npm/",
     "update:globle": "ncu -g --concurrency 10 --timeout 80000",
     "push": "start ./push.sh",
     "deploy": "start ./deploy.sh"

+ 2 - 0
src/config/setting.config.js

@@ -66,5 +66,7 @@ const setting = {
   templateFolder: 'project',
   //是否显示终端donation打印
   donation: true,
+  //是否开启图片压缩
+  imageCompression: true,
 }
 module.exports = setting

+ 10 - 8
vue.config.js

@@ -16,6 +16,7 @@ const {
   providePlugin,
   build7z,
   donation,
+  imageCompression,
 } = require('./src/config')
 const { webpackBarName, webpackBanner, donationConsole } = require('zx-layouts')
 
@@ -141,14 +142,15 @@ module.exports = {
         .plugin('banner')
         .use(Webpack.BannerPlugin, [`${webpackBanner}${time}`])
         .end()
-      config.module
-        .rule('images')
-        .use('image-webpack-loader')
-        .loader('image-webpack-loader')
-        .options({
-          bypassOnDebug: true,
-        })
-        .end()
+      if (imageCompression)
+        config.module
+          .rule('images')
+          .use('image-webpack-loader')
+          .loader('image-webpack-loader')
+          .options({
+            bypassOnDebug: true,
+          })
+          .end()
     })
 
     if (build7z) {