通用评论

config-overrides.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. const { injectBabelPlugin, compose } = require('react-app-rewired');
  2. const rewireCssModules = require('react-app-rewire-css-modules');
  3. const rewireLess = require('react-app-rewire-less');
  4. const WebpackVersionFilePlugin = require('webpack-version-file-plugin');
  5. const execa = require('execa');
  6. const path = require('path');
  7. const gitHash = execa.sync('git', ['rev-parse', '--short', 'HEAD']).stdout;
  8. const gitNumCommits = Number(execa.sync('git', ['rev-list', 'HEAD', '--count']).stdout);
  9. const gitDirty = execa.sync('git', ['status', '-s', '-uall']).stdout.length > 0;
  10. module.exports = compose(
  11. rewireCssModules,
  12. )
  13. module.exports = function override(config, env) {
  14. const rewires = compose(
  15. // rewireCssModules,
  16. rewireLess
  17. );
  18. config.plugins.push(new WebpackVersionFilePlugin({
  19. packageFile: path.join(__dirname, 'package.json'),
  20. template: path.join(__dirname, 'version.ejs'),
  21. outputFile: path.join(__dirname, '/src/version.json'),
  22. extras: {
  23. 'githash': gitHash,
  24. 'gitNumCommits': gitNumCommits,
  25. 'timestamp': Date.now(),
  26. 'dirty': gitDirty
  27. }
  28. }));
  29. config = injectBabelPlugin(['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }], config);
  30. return rewires(config, env);
  31. };