vue.config.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const resolve = dir => {
  4. return path.join(__dirname, dir)
  5. };
  6. // 线上打包路径,请根据项目实际线上情况
  7. const BASE_URL = process.env.NODE_ENV === 'production' ? '/api' : '/api';
  8. module.exports = {
  9. publicPath: BASE_URL,
  10. outputDir: 'dist', // 打包生成的生产环境构建文件的目录
  11. assetsDir: '', // 放置生成的静态资源路径,默认在outputDir
  12. indexPath: 'index.html', // 指定生成的 index.html 输入路径,默认outputDir
  13. pages: undefined, // 构建多页
  14. productionSourceMap: false, // 开启 生产环境的 source map?
  15. chainWebpack: config => {
  16. // 配置路径别名
  17. config.resolve.alias
  18. .set('@', resolve('src'))
  19. .set('_c', resolve('src/components'))
  20. },
  21. css: {
  22. modules: false, // 启用 CSS modules
  23. extract: true, // 是否使用css分离插件
  24. sourceMap: false, // 开启 CSS source maps?
  25. loaderOptions: {} // css预设器配置项
  26. },
  27. devServer: {
  28. open: true,
  29. port: 8000, // 端口
  30. disableHostCheck: false,
  31. https: false,
  32. hotOnly: false,
  33. proxy:{
  34. '/api': {
  35. target: 'http://192.168.1.200:8080', // 设置代理
  36. ws: true,
  37. changeOrigin: true,
  38. pathRewrite: {
  39. '^/api': '/'
  40. }
  41. }
  42. }
  43. },
  44. configureWebpack: {
  45. plugins: [
  46. new webpack.ProvidePlugin({
  47. $: "jquery",
  48. jQuery: "jquery",
  49. "windows.jQuery": "jquery"
  50. })
  51. ]
  52. }
  53. };