config-overrides.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Created by Arison on 2018/10/25.
  3. */
  4. const {injectBabelPlugin} = require('react-app-rewired');
  5. const rewireLess = require('react-app-rewire-less');
  6. const path = require('path')
  7. module.exports = function override(config, env) {
  8. config = injectBabelPlugin(
  9. ['import',
  10. {
  11. libraryName: 'antd',
  12. libraryDirectory: 'es',
  13. style: true
  14. }, 'ant'
  15. ],
  16. config
  17. );
  18. config = injectBabelPlugin(
  19. ['import',
  20. {
  21. libraryName: "antd-mobile",
  22. libraryDirectory: 'lib',
  23. style: true
  24. }, 'ant-mobile'
  25. ],
  26. config
  27. );
  28. config = rewireLess.withLoaderOptions({
  29. modifyVars: {"@primary-color": "#4197FC"},
  30. javascriptEnabled: true,
  31. })(config, env);
  32. //配置替代路径
  33. config.resolve.alias = {
  34. '@': path.join(__dirname, './src'),
  35. 'components': path.join(__dirname, './src/components'),
  36. 'configs': path.join(__dirname, './src/configs'),
  37. 'model': path.join(__dirname, './src/model'),
  38. 'modules': path.join(__dirname, './src/modules'),
  39. 'style': path.join(__dirname, './src/style'),
  40. 'utils': path.join(__dirname, './src/utils'),
  41. 'css': path.join(__dirname, './src/style/css'),
  42. 'imgs': path.join(__dirname, './src/style/imgs'),
  43. 'api': path.join(__dirname, './src/configs/api.config.js'),
  44. 'action': path.join(__dirname, './src/redux/actions')
  45. }
  46. return config;
  47. };