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