vue.config.js 2.4 KB

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