index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* eslint-disable no-unused-vars */
  2. /* eslint-disable import/no-commonjs */
  3. const path = require('path')
  4. const config = {
  5. projectName: 'GGW',
  6. date: '2021-1-27',
  7. designWidth: 750,
  8. deviceRatio: {
  9. 640: 2.34 / 2,
  10. 750: 1,
  11. 828: 1.81 / 2
  12. },
  13. sourceRoot: 'src',
  14. outputRoot: 'dist',
  15. alias: {
  16. '@': path.resolve(__dirname,'..','src')
  17. },
  18. plugins: [],
  19. defineConstants: {
  20. },
  21. copy: {
  22. patterns: [
  23. ],
  24. options: {
  25. }
  26. },
  27. framework: 'react',
  28. mini: {
  29. postcss: {
  30. pxtransform: {
  31. enable: true,
  32. config: {
  33. }
  34. },
  35. url: {
  36. enable: true,
  37. config: {
  38. limit: 1024 // 设定转换尺寸上限
  39. }
  40. },
  41. cssModules: {
  42. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  43. config: {
  44. namingPattern: 'module', // 转换模式,取值为 global/module
  45. generateScopedName: '[name]__[local]___[hash:base64:5]'
  46. }
  47. }
  48. },
  49. webpackChain(chain, _webpack) {
  50. // linaria/loader 选项详见 https://github.com/callstack/linaria/blob/master/docs/BUNDLERS_INTEGRATION.md#webpack
  51. chain.module
  52. .rule('script')
  53. .use('linariaLoader')
  54. .loader('linaria/loader')
  55. .options({
  56. sourceMap: process.env.NODE_ENV !== 'production',
  57. })
  58. }
  59. },
  60. h5: {
  61. publicPath: '/',
  62. staticDirectory: 'static',
  63. postcss: {
  64. autoprefixer: {
  65. enable: true,
  66. config: {
  67. }
  68. },
  69. cssModules: {
  70. enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
  71. config: {
  72. namingPattern: 'module', // 转换模式,取值为 global/module
  73. generateScopedName: '[name]__[local]___[hash:base64:5]'
  74. }
  75. }
  76. }
  77. }
  78. }
  79. export default function (merge) {
  80. if (process.env.NODE_ENV === 'development') {
  81. return merge({}, config, require('./dev'))
  82. }
  83. return merge({}, config, require('./prod'))
  84. }