Browse Source

webpack配置修改

谢杰标 2 years ago
parent
commit
1d501a0110

+ 1 - 1
build/build.js

@@ -1,7 +1,7 @@
 'use strict'
 'use strict'
 require('./check-versions')()
 require('./check-versions')()
 
 
-process.env.NODE_ENV = 'production'
+// process.env.NODE_ENV = 'production'
 
 
 const ora = require('ora')
 const ora = require('ora')
 const rm = require('rimraf')
 const rm = require('rimraf')

+ 15 - 3
build/webpack.prod.conf.js

@@ -11,7 +11,19 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin')
 const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
 const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
 const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
 const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
 
 
-const env = require('../config/prod.env')
+let env
+switch (process.env.ENV_ID) {
+  case '145':
+    env = require('../config/145.env')
+    break;
+  case '520':
+    env = require('../config/520.env')
+  case 'test':
+    env = require('../config/test.env')
+  default:
+    env = require('../config/prod.env')
+    break;
+}
 
 
 const webpackConfig = merge(baseWebpackConfig, {
 const webpackConfig = merge(baseWebpackConfig, {
   module: {
   module: {
@@ -65,7 +77,7 @@ const webpackConfig = merge(baseWebpackConfig, {
     new HtmlWebpackPlugin({
     new HtmlWebpackPlugin({
       filename: config.build.index,
       filename: config.build.index,
       template: 'index.html',
       template: 'index.html',
-      favicon:'./src/assets/favicon.ico',
+      favicon: './src/assets/favicon.ico',
       inject: true,
       inject: true,
       minify: {
       minify: {
         removeComments: true,
         removeComments: true,
@@ -84,7 +96,7 @@ const webpackConfig = merge(baseWebpackConfig, {
     // split vendor js into its own file
     // split vendor js into its own file
     new webpack.optimize.CommonsChunkPlugin({
     new webpack.optimize.CommonsChunkPlugin({
       name: 'vendor',
       name: 'vendor',
-      minChunks (module) {
+      minChunks(module) {
         // any required modules inside node_modules are extracted to vendor
         // any required modules inside node_modules are extracted to vendor
         return (
         return (
           module.resource &&
           module.resource &&

+ 9 - 0
config/145.env.js

@@ -0,0 +1,9 @@
+'use strict'
+module.exports = {
+    NODE_ENV: '"production"',
+    BASE_IMG_URL: '"https://file.xyyxt.net/"', //图片上传api
+    BASE_URL: '"https://api.xyyxt.net"',
+    TENANT_ID: '"141250585240548145"',
+    WEAPP_LOGO: '', // 微信小程序扫码图片
+    TENANT_NANE: '"中正云学堂"'
+}

+ 9 - 0
config/520.env.js

@@ -0,0 +1,9 @@
+'use strict'
+module.exports = {
+    NODE_ENV: '"production"',
+    BASE_IMG_URL: '"https://file.xyyxt.net/"', //图片上传api
+    BASE_URL: '"https://api.xyyxt.net"',
+    TENANT_ID: '"141250585240548145"',
+    WEAPP_LOGO: '', // 微信小程序扫码图片
+    TENANT_NANE: '"中正云学堂"'
+}

+ 8 - 5
config/dev.env.js

@@ -1,7 +1,10 @@
 'use strict'
 'use strict'
-const merge = require('webpack-merge')
-const prodEnv = require('./prod.env')
+module.exports = {
+  NODE_ENV: '"development"',
+  BASE_IMG_URL: '"https://file-dev.xyyxt.net/"', //图片上传api
+  BASE_URL: '"http://120.79.166.78:19012"',
+  TENANT_ID: '"867735392558919680"',
+  WEAPP_LOGO: '"@/assets/xcxqrcode.jpg"', // 微信小程序扫码图片
+  TENANT_NANE: '"祥粤云学堂"'
+}
 
 
-module.exports = merge(prodEnv, {
-  NODE_ENV: '"development"'
-})

+ 6 - 1
config/prod.env.js

@@ -1,4 +1,9 @@
 'use strict'
 'use strict'
 module.exports = {
 module.exports = {
-  NODE_ENV: '"production"'
+  NODE_ENV: '"production"',
+  BASE_IMG_URL: '"https://file.xyyxt.net/"', //图片上传api
+  BASE_URL: '"https://api.xyyxt.net"',
+  TENANT_ID: '"867735392558919680"',
+  WEAPP_LOGO: '"@/assets/xcxqrcode.jpg"', // 微信小程序扫码图片
+  TENANT_NANE: '"祥粤云学堂"'
 }
 }

+ 9 - 0
config/test.env.js

@@ -0,0 +1,9 @@
+module.exports = {
+    NODE_ENV: '"development"',
+    BASE_IMG_URL: '"https://file-dev.xyyxt.net/"', //图片上传api
+    BASE_URL: '"http://120.79.166.78:19012"',
+    TENANT_ID: '"867735392558919680"',
+    WEAPP_LOGO: '"@/assets/xcxqrcode.jpg"', // 微信小程序扫码图片
+    TENANT_NANE: '"祥粤云学堂"'
+}
+

+ 4 - 2
package.json

@@ -7,7 +7,9 @@
   "scripts": {
   "scripts": {
     "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
     "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
     "start": "npm run dev",
     "start": "npm run dev",
-    "build": "node build/build.js"
+    "build": "node build/build.js",
+    "build:145": "cross-env NODE_ENV=production ENV_ID=145 node build/build.js",
+    "build:test": "cross-env NODE_ENV=production ENV_ID=test node build/build.js"
   },
   },
   "dependencies": {
   "dependencies": {
     "axios": "^0.26.1",
     "axios": "^0.26.1",
@@ -74,4 +76,4 @@
     "last 2 versions",
     "last 2 versions",
     "not ie <= 8"
     "not ie <= 8"
   ]
   ]
-}
+}

+ 4 - 5
src/axios.js

@@ -1,18 +1,17 @@
 import axios from 'axios'
 import axios from 'axios'
 import store from './store'
 import store from './store'
-import { Message } from 'element-ui'
 // export const BASE_URL = 'https://api.xyyxt.net'   //release
 // export const BASE_URL = 'https://api.xyyxt.net'   //release
 // export const BASE_URL = 'https://test.xyyxt.net'   //预发布
 // export const BASE_URL = 'https://test.xyyxt.net'   //预发布
-export const BASE_URL = 'http://120.79.166.78:19012'    //测试-外网
+export const BASE_URL = process.env.BASE_URL    //测试-外网
 // export const BASE_URL = 'http://192.168.1.222:5055'    //测试
 // export const BASE_URL = 'http://192.168.1.222:5055'    //测试
-export const tenantId = '867735392558919680'
+export const tenantId = process.env.TENANT_ID
 // export const tenantId = '141250585240548145'
 // export const tenantId = '141250585240548145'
 // export const tenantId = '667735392758919630'
 // export const tenantId = '667735392758919630'
 
 
 //图片上传api
 //图片上传api
 // export const BASE_IMG_URL = 'https://file.xyyxt.net/'     //release
 // export const BASE_IMG_URL = 'https://file.xyyxt.net/'     //release
-export const BASE_IMG_URL = 'https://file-dev.xyyxt.net/'  //test
-
+// export const BASE_IMG_URL = process.env.BASE_IMG_URL  //test
+console.log(process.env.BASE_URL,6666)
 import tools from './common/tools'
 import tools from './common/tools'
 import router from './router'
 import router from './router'
 
 

+ 1 - 3
src/common/tools.js

@@ -1,5 +1,3 @@
-
-import * as baseUrls from '@/axios.js'
 import store from '@/store/index.js'
 import store from '@/store/index.js'
 import router from '@/router/index.js'
 import router from '@/router/index.js'
 
 
@@ -23,7 +21,7 @@ export default {
 		} else if (url.indexOf("http") != -1 || url.indexOf("https") != -1 || url.indexOf("wxfile") != -1) {
 		} else if (url.indexOf("http") != -1 || url.indexOf("https") != -1 || url.indexOf("wxfile") != -1) {
 
 
 		} else {
 		} else {
-			url = baseUrls.BASE_IMG_URL + url
+			url = process.env.BASE_IMG_URL + url
 		}
 		}
 		if (scale) {
 		if (scale) {
 			url = url + "?x-oss-process=image/resize,w_" + width
 			url = url + "?x-oss-process=image/resize,w_" + width

+ 11 - 8
src/components/toolbar/index.vue

@@ -9,11 +9,7 @@
           >
           >
             扫码进入小程序
             扫码进入小程序
           </div>
           </div>
-          <img
-            style="width: 150px; height: 150px"
-            src="@/assets/xcxqrcode.jpg"
-            alt=""
-          />
+          <img style="width: 150px; height: 150px" :src="WEAPP_LOGO" alt="" />
         </div>
         </div>
         <div slot="reference">
         <div slot="reference">
           <img src="@/assets/qr.png" class="img" alt="" />
           <img src="@/assets/qr.png" class="img" alt="" />
@@ -30,8 +26,8 @@
     <div class="item">
     <div class="item">
       <el-popover placement="left" width="180" trigger="hover">
       <el-popover placement="left" width="180" trigger="hover">
         <div>
         <div>
-          <h2 style="font-size:16px;color:#000;">报名咨询</h2>
-          <p style="color:#999;">{{ header.serviceTel.time }}</p>
+          <h2 style="font-size: 16px; color: #000">报名咨询</h2>
+          <p style="color: #999">{{ header.serviceTel.time }}</p>
           <div
           <div
             v-for="(item, index) in getTel(header.serviceTel.tel)"
             v-for="(item, index) in getTel(header.serviceTel.tel)"
             :key="index"
             :key="index"
@@ -39,7 +35,12 @@
           >
           >
             <i
             <i
               class="el-icon-phone"
               class="el-icon-phone"
-              style="border-radius: 50%; border: 1px solid #000; padding: 2px;margin-right:8px;"
+              style="
+                border-radius: 50%;
+                border: 1px solid #000;
+                padding: 2px;
+                margin-right: 8px;
+              "
             ></i>
             ></i>
             {{ item }}
             {{ item }}
           </div>
           </div>
@@ -115,9 +116,11 @@ export default {
   data() {
   data() {
     return {
     return {
       scrollTimer: null,
       scrollTimer: null,
+      WEAPP_LOGO: require(process.env.WEAPP_LOGO),
     };
     };
   },
   },
   mounted() {
   mounted() {
+    // console.log(process.env.WEAPP_LOGO);
     if (this.$tools.isLogin()) {
     if (this.$tools.isLogin()) {
       this.getCartCount();
       this.getCartCount();
     }
     }