build-example.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import path from 'path'
  2. import gulp from 'gulp'
  3. import * as utils from './build-utils'
  4. import getOutput from './get-output'
  5. const srcPath = path.join(__dirname, '../src')
  6. const buildPath = `${getOutput()}/dist`
  7. const files = utils.files
  8. const paths = {
  9. styles: {
  10. src: [`${srcPath}/**/*.less`],
  11. dest: buildPath,
  12. },
  13. colors: {
  14. src: [`${srcPath}/helpers/colors.js`],
  15. dest: buildPath,
  16. },
  17. copy: {
  18. src: [`${srcPath}/**`, `!${srcPath}/**/*.less`, `!${srcPath}/icon/fonts/**`],
  19. dest: buildPath,
  20. },
  21. }
  22. paths.styles.src = [
  23. `${srcPath}/styles/*.less`,
  24. ...files.map((v) => `${srcPath}/${v}/*.less`),
  25. ]
  26. paths.copy.src = [
  27. ...files.map((v) => `${srcPath}/${v}/**`),
  28. `!${srcPath}/**/*.less`,
  29. `!${srcPath}/icon/fonts/**`,
  30. `${srcPath}/helpers/**`,
  31. // `${srcPath}/index.js`,
  32. // `${srcPath}/config.json`,
  33. ]
  34. const styles = utils.styles(paths.styles, srcPath, false)
  35. const copy = utils.copy(paths.copy, srcPath)
  36. const colors = utils.generateColors(paths.colors, srcPath, false)
  37. const watchFiles = () => {
  38. gulp.watch(paths.styles.src, styles)
  39. gulp.watch(paths.copy.src, copy)
  40. }
  41. export { watchFiles as watch }
  42. export default gulp.series(
  43. gulp.parallel(
  44. styles,
  45. copy,
  46. utils.generateFiles(buildPath, false),
  47. utils.generateConfig(buildPath),
  48. ),
  49. colors,
  50. )