vue.config.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. const Version = new Date().getTime();
  2. const webpack = require("webpack");
  3. module.exports = {
  4. lintOnSave: false,
  5. //配置 运行和打包时的文件路径
  6. // publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
  7. publicPath:'./',
  8. outputDir:'dist',
  9. // 放置生成的静态资源 (js、css、img、fonts)的目录,资源放的目录 。 (相对于 outputDir)
  10. assetsDir: "",
  11. // 指定生成的 index.html 的输出路径,也可以是一个绝对路径。index的路劲和名字 (相对于 outputDir 的)
  12. indexPath: 'index.html',
  13. css: {
  14. // 是否使用css分离插件 ExtractTextPlugin
  15. extract: {
  16. // 修改打包后css文件名
  17. filename: `./css/[name].${Version}.css`,
  18. chunkFilename: `./css/[name].${Version}.css`
  19. }
  20. },
  21. configureWebpack: {
  22. output: { // 输出重构 打包编译后的 文件名称 【模块名称.版本号.时间戳】
  23. filename: `./js/[name].${Version}.js`,
  24. chunkFilename: `./js/[name].${Version}.js`
  25. },
  26. plugins: [
  27. new webpack.ProvidePlugin({
  28. $:"jquery",
  29. jQuery:"jquery",
  30. "windows.jQuery":"jquery"
  31. })
  32. ]
  33. },
  34. pwa:{ // 配置浏览器标签图标
  35. iconPaths: {
  36. favicon32: 'favicon.ico',
  37. favicon16: 'favicon.ico',
  38. appleTouchIcon: 'favicon.ico',
  39. maskIcon: 'favicon.ico',
  40. msTileImage: 'favicon.ico'
  41. }
  42. },
  43. chainWebpack(config) {
  44. // img的文件名修改
  45. config.module
  46. .rule('images')
  47. .use('url-loader')
  48. .tap(options => {
  49. options.name = `./img/[name].${Version}.[ext]`
  50. options.fallback = {
  51. loader: 'file-loader',
  52. options: {
  53. name: `./img/[name].${Version}.[ext]`
  54. }
  55. }
  56. return options
  57. })
  58. },
  59. devServer: {
  60. proxy: {
  61. '/api': {
  62. // 此处的写法,目的是为了 将 /api 替换成 域名
  63. target: 'http://49.233.2.47:9000',
  64. // 允许跨域
  65. changeOrigin: true,
  66. ws: true,
  67. pathRewrite: {
  68. '^/api': ''
  69. }
  70. },
  71. '/api/chat':{
  72. target: "http://192.168.39.133:11434",
  73. changeOrigin: true,
  74. pathRewrite: {
  75. '^/api/generate': '' // 不重写路径
  76. }
  77. }
  78. }
  79. }
  80. }