You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.6 KiB

2 years ago
  1. import fs from 'fs'
  2. import postcss from 'postcss'
  3. import tailwind from '..'
  4. function build({ from, to, config }) {
  5. return new Promise((resolve, reject) => {
  6. console.log(`Processing ./${from}...`)
  7. fs.readFile(`./${from}`, (err, css) => {
  8. if (err) throw err
  9. return postcss([tailwind(config)])
  10. .process(css, {
  11. from: undefined,
  12. })
  13. .then((result) => {
  14. fs.writeFileSync(`./${to}`, result.css)
  15. return result
  16. })
  17. .then(resolve)
  18. .catch((error) => {
  19. console.log(error)
  20. reject()
  21. })
  22. })
  23. })
  24. }
  25. console.info('\nRebuilding fixtures...\n')
  26. Promise.all([
  27. build({
  28. from: 'tests/fixtures/tailwind-input.css',
  29. to: 'tests/fixtures/tailwind-output.css',
  30. config: {},
  31. }),
  32. build({
  33. from: 'tests/fixtures/tailwind-input.css',
  34. to: 'tests/fixtures/tailwind-output-important.css',
  35. config: { important: true },
  36. }),
  37. build({
  38. from: 'tests/fixtures/tailwind-input.css',
  39. to: 'tests/fixtures/tailwind-output-no-color-opacity.css',
  40. config: {
  41. corePlugins: {
  42. textOpacity: false,
  43. backgroundOpacity: false,
  44. borderOpacity: false,
  45. placeholderOpacity: false,
  46. divideOpacity: false,
  47. },
  48. },
  49. }),
  50. build({
  51. from: 'tests/fixtures/tailwind-input.css',
  52. to: 'tests/fixtures/tailwind-output-flagged.css',
  53. config: {
  54. future: 'all',
  55. experimental: 'all',
  56. },
  57. }),
  58. ]).then(() => {
  59. console.log('\nFinished rebuilding fixtures.')
  60. console.log(
  61. '\nPlease triple check that the fixture output matches what you expect before committing this change.'
  62. )
  63. })