Skip to content

Commit

Permalink
Minify CSS as postprocess step
Browse files Browse the repository at this point in the history
  • Loading branch information
oamaok committed Oct 17, 2021
1 parent 7555db4 commit 46ec1fc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions build/css-modules-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const CssModulesPlugin = () => ({
return scopedName
},
}),
cssnano({ preset: 'default' }),
]).process(await fs.readFile(filePath))

cssContent[filePath] = css
Expand All @@ -46,12 +45,14 @@ const CssModulesPlugin = () => ({

build.onEnd(async () => {
const bundlePath = resolve(build.initialOptions.outdir, 'index.css')
await fs.writeFile(
bundlePath,

const { css } = await postcss([cssnano({ preset: 'default' })]).process(
Object.keys(cssContent)
.map((key) => cssContent[key])
.join('\n')
)

await fs.writeFile(bundlePath, css)
})
},
})
Expand Down

0 comments on commit 46ec1fc

Please sign in to comment.