vue.config.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. const DonePlugin = require("./src/plugin/webpackDonePlugin.js");
  2. const WebpackBar = require("webpackbar");
  3. const TerserPlugin = require("terser-webpack-plugin");
  4. console.log('当前环境:', process.env.NODE_ENV);
  5. module.exports = {
  6. transpileDependencies: true,
  7. lintOnSave: false,
  8. chainWebpack: (config) => {
  9. config.module
  10. .rule("lottie")
  11. .test(/\.lottie$/)
  12. .use("file-loader")
  13. .loader("file-loader")
  14. .end();
  15. config.plugin('html').tap(args => {
  16. args[0].title = "慧教研-大数据精准教学诊断平台";
  17. return args
  18. })
  19. },
  20. publicPath: process.env.NODE_ENV === 'production' ? '/studata/' : '/',// /studata/ 生产环境(打包后)使用目标路径;/ 开发环境(npm run serve)使用根路径,不影响本地开发
  21. configureWebpack: {
  22. optimization: {
  23. minimize: true,
  24. minimizer: [
  25. new TerserPlugin({
  26. terserOptions: {
  27. compress: {
  28. drop_console: true,//// 移除所有 console.*
  29. drop_debugger: true,//// 移除所有 debugger.*
  30. pure_funcs: ["console.log"],
  31. },
  32. },
  33. }),
  34. ],
  35. },
  36. name: "教学管理大数据平台",
  37. devtool: "source-map",
  38. // entry:'./public/index.html',
  39. // resolve:{},
  40. // output:{
  41. // filename:'[name].js',
  42. // chunkFilename:'[name].js'
  43. // },
  44. plugins: [
  45. new DonePlugin(),
  46. // new WebpackBar({
  47. // basic: false,
  48. // name: 'JTZX-bigDataAdmin',
  49. // color: 'green'
  50. // })
  51. ],
  52. },
  53. // productionSourceMap: process.env.NODE_ENV !== 'production',
  54. productionSourceMap: false, // 生产环境关闭 sourceMap
  55. css: {
  56. extract: false,
  57. loaderOptions: {
  58. postcss: {
  59. // postcssOptions:{
  60. // plugins: [
  61. // require('postcss-pxtorem')({
  62. // rootValue: 14.4, // 根据设计稿宽度计算,例如设计稿宽度为 1920px,则 rootValue = 1920 / 100 = 19.2
  63. // propList: ['*'], // 需要转换的属性,* 表示所有属性
  64. // selectorBlackList: [], // 忽略的选择器
  65. // replace: false, // 替换 px 为 rem
  66. // mediaQuery: false, // 是否转换媒体查询中的 px
  67. // minPixelValue: 12 // 最小 px 值
  68. // })
  69. // ]
  70. // },
  71. }
  72. },
  73. },
  74. devServer: {
  75. open: false,
  76. hot: true,
  77. host: "",
  78. port: 8080,
  79. https: false,
  80. client: {
  81. overlay: {
  82. warnings: false,
  83. errors: true,
  84. runtimeErrors: false,
  85. },
  86. },
  87. proxy: {
  88. "/api": {
  89. // target: "https://dev3.k12100.net/student/api/",
  90. target: "http://192.168.1.15:47003/api/",
  91. changeOrigin: true,
  92. pathRewrite: {
  93. "^/api": "/",
  94. },
  95. },
  96. },
  97. },
  98. };