vue.config.js 3.7 KB

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