vue.config.js 2.3 KB

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