vue.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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' ? './' : './';
  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. port: 8080, // 端口
  29. // proxy: 'https://www.easy-mock.com' // 设置代理
  30. },
  31. configureWebpack: {
  32. plugins: [
  33. new webpack.ProvidePlugin({
  34. $: "jquery",
  35. jQuery: "jquery",
  36. "windows.jQuery": "jquery"
  37. })
  38. ]
  39. }
  40. };