-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpostcss.config.mjs
45 lines (37 loc) · 991 Bytes
/
postcss.config.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 url from 'postcss-url'
import postCssPresetEnv from 'postcss-preset-env'
import postCssFlexbugsFixes from 'postcss-flexbugs-fixes'
import { fingerprintUrl } from './src/features/infra/fingerprint.mjs'
import { getServerEnv } from './src/features/infra/env.mjs'
const { environment, build } = getServerEnv()
const assetsPath = '/assets/'
const fingerprintAsset = (asset) => {
const { url } = asset
if (environment.isDev) {
return url
}
if (!url.startsWith(assetsPath)) {
return url
}
if (!build.hash) {
return url
}
return fingerprintUrl(url, build.hash)
}
export default {
plugins: [
url({
url: (asset) => fingerprintAsset(asset)
}),
postCssPresetEnv({
stage: 2,
browsers: 'last 2 versions or > 3%',
features: {
'custom-media-queries': {
importFrom: 'node_modules/open-props/media.min.css'
}
}
}),
postCssFlexbugsFixes
]
}