gzpt2.0-h5适老版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
5.3 KiB

2 years ago
2 years ago
  1. const autoprefixer = require("autoprefixer");
  2. const pxtorem = require("postcss-pxtorem");
  3. const path = require('path');
  4. const themePath = path.resolve(__dirname,'src/assets/style/theme.less');
  5. const CompressionWebpackPlugin = require('compression-webpack-plugin')
  6. const productionGzipExtensions = ['js', 'css']
  7. const isProduction = process.env.NODE_ENV === 'production'
  8. var webpack = require('webpack');
  9. const Timestamp = new Date().getTime();
  10. module.exports = {
  11. // publicPath: '/jjt/',//中台调试打开
  12. publicPath: './',//浙里办正式打开
  13. productionSourceMap: false,
  14. outputDir: process.env.NODE_ENV === "production" ? "build" : "build",
  15. // 关闭eslint检查
  16. lintOnSave: false,
  17. // 配置css前缀,px转rem
  18. css: {
  19. loaderOptions: {
  20. less: {
  21. // http://lesscss.org/usage/#less-options-strict-units `Global Variables`
  22. // `primary` is global variables fields name
  23. // modifyVars: {
  24. // // 直接覆盖变量
  25. // "text-color": "#111",
  26. // "border-color": "#eee",
  27. // "nav-bar-text-color": "#c03131",
  28. // "van-nav-bar__text": "#c03131",
  29. // "nav-bar-title-text-color": "#c03131",
  30. // // 或者可以通过 less 文件覆盖(文件路径为绝对路径)
  31. // // hack: `true; @import "@/assets/style/my-theme.less";`
  32. // }
  33. modifyVars: {
  34. hack: `true; @import "${themePath}";`
  35. }
  36. },
  37. postcss: {
  38. plugins: [
  39. autoprefixer(),
  40. pxtorem({
  41. rootValue: 37.5,
  42. propList: ["*"]
  43. })
  44. ]
  45. }
  46. }
  47. },
  48. configureWebpack: {
  49. externals: {
  50. // axios: "axios",// 配置使用CDN
  51. "AMap": "AMap"
  52. },
  53. resolve:{
  54. alias:{
  55. '@':path.resolve(__dirname, './src'),
  56. '@i':path.resolve(__dirname, './src/assets'),
  57. }
  58. },
  59. output: { // 输出重构 打包编译后的 文件名称 【模块名称.版本号.时间戳】
  60. filename: `static/js/[name].${Timestamp}.js`,
  61. chunkFilename: `static/js/[name].${Timestamp}.js`
  62. },
  63. plugins: [
  64. // Ignore all locale files of moment.js
  65. new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
  66. // 配置compression-webpack-plugin压缩
  67. new CompressionWebpackPlugin({
  68. algorithm: 'gzip',
  69. test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  70. threshold: 10240,
  71. minRatio: 0.8
  72. }),
  73. new webpack.optimize.LimitChunkCountPlugin({
  74. maxChunks: 5,
  75. minChunkSize: 100
  76. })
  77. ]
  78. },
  79. // css: {
  80. // loaderOptions: {
  81. // // 给 less-loader 传递 Less.js 相关选项
  82. // less: {
  83. // // http://lesscss.org/usage/#less-options-strict-units `Global Variables`
  84. // // `primary` is global variables fields name
  85. // // modifyVars: {
  86. // // // 直接覆盖变量
  87. // // "text-color": "#111",
  88. // // "border-color": "#eee",
  89. // // "nav-bar-text-color": "#c03131",
  90. // // "van-nav-bar__text": "#c03131",
  91. // // "nav-bar-title-text-color": "#c03131",
  92. // // // 或者可以通过 less 文件覆盖(文件路径为绝对路径)
  93. // // // hack: `true; @import "@/assets/style/my-theme.less";`
  94. // // }
  95. // modifyVars: {
  96. // red: "#03a9f4",
  97. // blue: "#3eaf7c",
  98. // orange: "#f08d49",
  99. // "text-color": "#111"
  100. // }
  101. // }
  102. // }
  103. // }
  104. // chainWebpack: config => {
  105. // const lessRule = config.module.rule("less");
  106. // lessRule.uses.clear();
  107. // lessRule
  108. // .test(/\.less$/)
  109. // .use("style-loader")
  110. // .loader("css-loader")
  111. // .loader("less-loader")
  112. // .options({
  113. // modifyVars: {
  114. // // 直接覆盖变量
  115. // "text-color": "#111",
  116. // "border-color": "#eee",
  117. // // 或者可以通过 less 文件覆盖(文件路径为绝对路径)
  118. // hack: `true; @import "@/assets/style/my-theme.less";`
  119. // }
  120. // });
  121. // }
  122. // // 自定义主题样式
  123. // rules: [
  124. // {
  125. // test: /\.less$/,
  126. // use: [
  127. // // ...其他 loader 配置
  128. // {
  129. // loader: "less-loader",
  130. // options: {
  131. // modifyVars: {
  132. // // 直接覆盖变量
  133. // "text-color": "#111",
  134. // "border-color": "#eee",
  135. // // 或者可以通过 less 文件覆盖(文件路径为绝对路径)
  136. // hack: `true; @import "@/assets/style/my-theme.less";`
  137. // }
  138. // }
  139. // }
  140. // ]
  141. // }
  142. // ]
  143. devServer: {
  144. disableHostCheck: true,
  145. // 代理
  146. proxy: {
  147. // 只要请求地址有'api'都会匹配上
  148. "/api": {
  149. target: "https://www.jaxc.cn/jjtapi/", //测试(缙驾通临时用)
  150. // target: "http://118.31.18.45:6630/", //测试(缙驾通临时用)
  151. //target:"https://www.jaxc.cn/student/",
  152. // target:"http://121.41.97.244:6085/", //测试环境
  153. // target: "http://121.41.97.244:6630/api/", //朱工本地
  154. ws: true,
  155. // 允许跨域
  156. changeOrigin: true,
  157. pathRewrite: {
  158. "^/api": "" //通过pathRewrite重写地址,将前缀/api转为/
  159. }
  160. },
  161. }
  162. }
  163. };