vue.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. const {defineConfig} = require('@vue/cli-service')
  2. module.exports = defineConfig({
  3. transpileDependencies: true,
  4. // chainWebpack: (config) => {
  5. // // config.resolve.alias.set("@$", resolve("src")).set("@views", resolve("src/views"));
  6. // },
  7. // lintOnSave: false,
  8. css: {
  9. loaderOptions: {
  10. less: {
  11. // 若 less-loader 版本小于 6.0,请移除 lessOptions 这一级,直接配置选项。
  12. modifyVars: {
  13. // 或者可以通过 less 文件覆盖(文件路径为绝对路径)
  14. hack: `true; @import "./src/assets/theme.less";`,
  15. },
  16. },
  17. },
  18. },
  19. devServer: {
  20. client: {
  21. overlay: false
  22. },
  23. hot: true, //支持热更新
  24. port: 8080,
  25. host: "0.0.0.0",
  26. proxy: {
  27. '/api': {
  28. target: 'https://api.ruanjian168.cc', //后期可以改
  29. changeOrigin: true,
  30. logLevel: 'debug',
  31. pathRewrite: {
  32. '^/api': '/api'
  33. }
  34. }
  35. }
  36. //contentBase:path.resolve(__dirname,'static') //指定(额外的)静态文件目录, // 如果使用 CopyWebpackPlugin ,设置为false
  37. // eslint-disable-next-line no-unused-vars
  38. },
  39. configureWebpack: {
  40. optimization: {
  41. splitChunks: {
  42. cacheGroups: {
  43. app: {
  44. chunks: "all",
  45. name: "main",
  46. test: /[\\/]src[\\/](.*)[\\/]/,
  47. },
  48. vendor: {
  49. test: /[\\/]node_modules[\\/][\\/]/,
  50. name: "vendor",
  51. chunks: "all",
  52. },
  53. },
  54. },
  55. },
  56. },
  57. publicPath: "./",
  58. outputDir: "dist",
  59. assetsDir: "assets",
  60. runtimeCompiler: true,
  61. })