1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
| /*
| * @Author: shuishen 1109946754@qq.com
| * @Date: 2022-09-07 09:37:07
| * @LastEditors: shuishen 1109946754@qq.com
| * @LastEditTime: 2023-07-11 14:16:32
| * @FilePath: \srs-police-affairs\vue.config.js
| * @Description:
| *
| * Copyright (c) 2022 by shuishen 1109946754@qq.com, All Rights Reserved.
| */
|
| const path = require("path")
| const CopywebpackPlugin = require("copy-webpack-plugin")
| const dvgisDist = "./node_modules/@dvgis"
| const webpack = require("webpack")
|
| const CompressionPlugin = require("compression-webpack-plugin")
| const pxtovw = require("postcss-px-to-viewport")
|
| const productionGzipExtensions = ["js", "css"]
|
| module.exports = {
| css: {
| loaderOptions: {
| // 给 sass-loader 传递选项
| scss: {
| prependData: `@import "~@/styles/scssFile.scss";`,
| },
| // postcss: {
| // plugins: [ //配置px转rem进行适配
| // require('postcss-px2rem')({
| // // 根标签字号大小根据设计稿宽度/flexible.js里的份数得到,这里假定设计稿宽度为3840 3840/24 = 160px
| // remUnit: 80
| // }),
| // ]
| // }
| // postcss: {
| // //给postcss-loader传递选项
| // plugins: [
| // new pxtovw({
| // unitToConvert: 'px', //需要转换的单位,默认为"px";
| // viewportWidth: 1920, //设计稿的视口宽度
| // viewportHeight: 1080, //设计稿的视口宽度
| // unitPrecision: 5, //单位转换后保留的小数位数
| // propList: ['*'], //要进行转换的属性列表,*表示匹配所有,!表示不转换
| // viewportUnit: 'vw', //转换后的视口单位
| // fontViewportUnit: 'vw', //转换后字体使用的视口单位
| // selectorBlackList: [], //不进行转换的css选择器,继续使用原有单位
| // minPixelValue: 1, //设置最小的转换数值
| // mediaQuery: false, //设置媒体查询里的单位是否需要转换单位
| // replace: true, //是否直接更换属性值,而不添加备用属性
| // exclude: [/node_modules/], //忽略某些文件夹下的文件
| // // landscape: true,
| // // landscapeUnit: 'vw',
| // // landscapeWidth: 1920
| // })
| // ]
| // }
| },
| },
|
| // 其他配置
| chainWebpack: (config) => {
| config.plugin("copy").use(CopywebpackPlugin, [
| [
| {
| from: path.join(dvgisDist, "dc-sdk/dist/resources"),
| to: "libs/dc-sdk/resources",
| },
| {
| from: "./public/img",
| to: "img",
| },
| {
| from: "./public/model",
| to: "model",
| },
| {
| from: "./public/video",
| to: "video",
| },
| {
| from: "./public/libs",
| to: "libs",
| },
| {
| from: "./public/depend",
| to: "depend",
| },
| {
| from: "./public/static",
| to: "static",
| },
| {
| from: "./public/images",
| to: "images",
| },
| {
| from: "./public/qp",
| to: "qp",
| },
| {
| from: "./public/warnings",
| to: "warnings",
| },
| ],
| ])
|
| // config.plugin("define").tap((args) => {
| // args[0]["process"] = { ...args[0]["process.env"] }
| // return args
| // })
| },
|
| configureWebpack: {
| externals: {
| vue: "Vue",
| Vuex: "Vuex",
| "vue-router": "VueRouter",
| "element-ui": "ELEMENT",
| echarts: "echarts",
| },
| // webpack plugins
| plugins: [
| // Ignore all locale files of moment.js
| new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
| // 配置compression-webpack-plugin压缩
| new CompressionPlugin({
| algorithm: "gzip",
| test: new RegExp("\\.(" + productionGzipExtensions.join("|") + ")$"),
| threshold: 10240,
| minRatio: 0.8,
| }),
| new webpack.optimize.LimitChunkCountPlugin({
| maxChunks: 5,
| minChunkSize: 100,
| }),
| // 提供带 Content-Encoding 编码的压缩版的资源
| // new CompressionPlugin({
| // algorithm: 'gzip',
| // test: /\.js$|\.html$|\.css/, // 匹配文件名
| // // test: /\.(js|css)$/,
| // threshold: 10240, // 对超过10k的数据压缩
| // deleteOriginalAssets: false, // 不删除源文件
| // minRatio: 0.8 // 压缩比
| // })
| ],
| },
|
| devServer: {
| // open: false, // 编译完成是否打开网页
| // host: "0.0.0.0", // 指定使用地址,默认localhost,0.0.0.0代表可以被外界访问
| // // port: 82, // 访问端口
| // https: false, // 编译失败时刷新页面
| // hot: true, // 开启热加载
| // hotOnly: false,
| // proxy: {
| // [process.env.VUE_APP_API]: {//拦截器(拦截链接中有/api)
| // target: process.env.VUE_API_DEV_TARGET,//'http://192.168.1.114:3000', //process.env.VUE_API_DEV_TARGET, //API服务器的地址
| // changeOrigin: true,
| // pathRewrite: {
| // //'^/api': '/'
| // [`^${process.env.VUE_APP_API}`]: '',
| // //[`^${process.env.VUE_APP_API}`]: '/', //配置出来的接口没有 /api
| // }
| // }
| // }
| proxy: {
| "/api": {
| // target用于配置你允许访问数据的计算机名称,即是你的api接口的服务器地址
| target: "http://localhost:82",
| // target: "http://z4042833u6.wicp.vip",
| // target: "http://192.168.1.177:82",
| // target: "http://106.225.193.35:82",
| // target: "http://192.168.1.170:82",
| // target: "http://192.168.0.100:82",
| // target: "http://172.16.13.150:82",
| // target: "http://10.141.11.11:8081/api",
| // ws: true, //启用webSocket6566
| changeOrigin: true, //开启代理跨域
| pathRewrite: {
| "^/api": "",
| },
| },
| },
| },
| }
|
|