forked from dnum-mi/vue-dsfr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-css.mjs
45 lines (40 loc) · 1.14 KB
/
build-css.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import fs from 'fs'
import mkdirp from 'mkdirp'
import postcss from 'postcss'
import atImport from 'postcss-import'
import postcssUrl from 'postcss-url'
import csso from 'postcss-csso'
const postcssPlugins = [
atImport(),
postcssUrl({ url: 'inline' }),
csso(),
]
mkdirp.sync('dist')
fs.readFile('./src/assets/variables-fdr.css', 'utf8', (err, css) => {
if (err) {
console.error(err)
throw err
}
postcss(postcssPlugins)
.process(css, { from: 'src/assets/variables-fdr.css', to: 'dist/variables-fdr.css' })
.then(result => {
fs.writeFile('dist/variables-fdr.css', result.css, () => true)
if (result.map) {
fs.writeFile('dist/variables-fdr.css.map', result.map.toString(), () => true)
}
})
})
fs.readFile('./src/main.css', 'utf8', (err, css) => {
if (err) {
console.error(err)
throw err
}
postcss(postcssPlugins)
.process(css, { from: 'src/main.css', to: 'dist/vue-dsfr.css' })
.then(result => {
fs.writeFile('dist/vue-dsfr.css', result.css, () => true)
if (result.map) {
fs.writeFile('dist/vue-dsfr.css.map', result.map.toString(), () => true)
}
})
})