vue.config.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // vue.config.js
  2. const path = require('path');
  3. module.exports = {
  4. productionSourceMap: process.env.NODE_ENV != 'production',
  5. publicPath: './',
  6. devServer: {
  7. host: '0.0.0.0',
  8. disableHostCheck: true,
  9. open: true,
  10. proxy: {
  11. '/devServer': {
  12. target: 'https://jelly.jd.com',
  13. changeOrigin: true,
  14. pathRewrite: {
  15. '^/devServer': ''
  16. }
  17. }
  18. }
  19. },
  20. css: {
  21. loaderOptions: {
  22. // 给 sass-loader 传递选项
  23. // prependData: {
  24. // // @/ 是 src/ 的别名
  25. // // 所以这里假设你有 `src/variables.sass` 这个文件
  26. // // 注意:在 sass-loader v8 中,这个选项名是 "prependData"
  27. // additionalData: `@import "~@/styles/variables.sass"`,
  28. // },
  29. // 默认情况下 `sass` 选项会同时对 `sass` 和 `scss` 语法同时生效
  30. // 因为 `scss` 语法在内部也是由 sass-loader 处理的
  31. // 但是在配置 `prependData` 选项的时候
  32. // `scss` 语法会要求语句结尾必须有分号,`sass` 则要求必须没有分号
  33. // 在这种情况下,我们可以使用 `scss` 选项,对 `scss` 语法进行单独配置
  34. scss: {
  35. additionalData: `@import "~@/styles/variables.scss";@import "~@/sites/assets/styles/variables.scss";`
  36. }
  37. }
  38. },
  39. pages: {
  40. doc: {
  41. entry: 'src/sites/doc/main.ts',
  42. template: 'src/sites/doc/index.html',
  43. filename: 'index.html',
  44. // template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
  45. title: 'NutUI',
  46. // 在这个页面中包含的块,默认情况下会包含
  47. // 提取出来的通用 chunk 和 vendor chunk。
  48. chunks: ['chunk-vendors', 'chunk-common', 'doc']
  49. },
  50. mobile: {
  51. entry: 'src/sites/mobile/main.ts',
  52. template: 'src/sites/mobile/index.html',
  53. filename: 'demo.html',
  54. // template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
  55. title: 'NutUI',
  56. // 在这个页面中包含的块,默认情况下会包含
  57. // 提取出来的通用 chunk 和 vendor chunk。
  58. chunks: ['chunk-vendors', 'chunk-common', 'mobile']
  59. }
  60. },
  61. configureWebpack: {
  62. optimization: {
  63. minimize: process.env.NODE_ENV === 'production',
  64. splitChunks: {
  65. automaticNameDelimiter: '_'
  66. }
  67. }
  68. },
  69. chainWebpack: config => {
  70. config.module
  71. .rule('md-vue')
  72. .test(/\.md$/)
  73. .use('vue-loader')
  74. .loader('vue-loader')
  75. .end()
  76. .use(path.resolve(__dirname, './loader/md-vue/index.js'))
  77. .loader(path.resolve(__dirname, './loader/md-vue/index.js'))
  78. .end();
  79. }
  80. };