vue.config.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. const webpack = require('webpack')
  2. const path = require('path');
  3. function resolve (dir) {
  4. return path.join(__dirname, dir)
  5. }
  6. // 项目的主要配置文件
  7. module.exports = {
  8. publicPath: '',
  9. outputDir: './dist',
  10. productionSourceMap: false,
  11. lintOnSave: false,
  12. //启用并行化 默认并发运行数 os.cpus().length - 1 ,并行化可以显著加速构建
  13. parallel: require('os').cpus().length > 1,
  14. configureWebpack: {
  15. plugins: [
  16. new webpack.ProvidePlugin({
  17. $: 'jquery',
  18. jQuery: 'jquery',
  19. 'windows.jQuery': 'jquery',
  20. 'window.Quill': 'quill/dist/quill.js',
  21. 'Quill': 'quill/dist/quill.js'
  22. }),
  23. ]
  24. },
  25. chainWebpack: (config)=>{
  26. //修改文件引入自定义路径
  27. config.resolve.alias
  28. .set('@', resolve('src'))
  29. config.resolve.alias
  30. .set('@utils', resolve('src/utils'))
  31. },
  32. pages: {
  33. index: {
  34. // 页面入口
  35. entry: 'src/main.js',
  36. // 模板来源
  37. template: 'public/index.html',
  38. // 在 dist/index.html 的输出
  39. filename: 'index.html',
  40. // 当使用 title 选项时,
  41. // template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
  42. title: '重庆市市级生态环境监测专家库管理系统',
  43. // 在这个页面中包含的块,默认情况下会包含提取出来的通用 chunk 和 vendor chunk
  44. chunks: ['chunk-vendors', 'chunk-common', 'index']
  45. },
  46. // 当使用只有入口的字符串格式时,
  47. // 模板会被推导为 `public/subpage.html`
  48. // 并且如果找不到的话,就回退到 `public/index.html`
  49. // 输出文件名会被推导为 `subpage.html`
  50. subpage: 'src/main.js'
  51. },
  52. css: {
  53. // 是否使用css分离插件
  54. //生产环境下是 true,开发环境下是 false
  55. extract: false,
  56. // 开启 CSS source maps?
  57. sourceMap: false,
  58. // css预设器配置项
  59. loaderOptions: {},
  60. // 启用 CSS modules
  61. requireModuleExtension: true,
  62. },
  63. devServer: { // 接口反向代理
  64. open: false,
  65. port: 8028,
  66. /*proxy: { // 单位管理接口
  67. "/api": {
  68. target: process.env.VUE_APP_URL,
  69. changeOrigin: true,
  70. // ws: true, // proxy websockets
  71. pathRewrite: {
  72. "^/api": ""
  73. }
  74. }
  75. }*/
  76. }
  77. }