-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.js
More file actions
39 lines (37 loc) · 1.31 KB
/
build.js
File metadata and controls
39 lines (37 loc) · 1.31 KB
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
import fs from 'fs'
import path from 'path'
import postcss from 'postcss'
import tailwind from 'tailwindcss';
import autoprefixer from 'autoprefixer';
import cssnano from 'cssnano';
import atImport from 'postcss-import';
import presetEnv from 'postcss-preset-env';
import importSvg from 'postcss-import-svg';
import { breakpoints as customMedia } from './src/utils/tailwind/colors.js'
import tailwindConfig from './src/utils/tailwind/tailwind.config.js'
import { createRequire } from 'module'
const require = createRequire(import.meta.url) // have to do these hacks it seems because import.meta.resolve is cranky
const iconsLocation = path.resolve(path.dirname(require.resolve('@fabric-ds/icons/package.json')), 'dist')
const from = './src/fabric.css'
const to = './dist/fabric.min.css'
const css = fs.readFileSync(from, 'utf-8')
const plugins = [
atImport,
tailwind(tailwindConfig),
presetEnv({
stage: 0,
browsers: 'extends @finn-no/browserslist-config',
importFrom: { customMedia },
features: {
'focus-visible-pseudo-class': false,
},
}),
importSvg({
paths: [iconsLocation],
}),
autoprefixer,
cssnano({ preset: 'default' })
]
const result = await postcss(plugins).process(css, { from, to })
fs.mkdirSync('./dist', { recursive: true })
fs.writeFileSync(to, result.css, { encoding: 'utf-8' })