Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cssnano on production #171

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,23 @@
nuxt.options.nitro = nuxt.options.nitro || {}
nuxt.options.nitro.publicAssets = nuxt.options.nitro.publicAssets || []
nuxt.options.nitro.publicAssets.push({ dir: outputDir })

// Setup postcss plugins
// https://github.com/nuxt-modules/google-fonts/issues/158
if (process.env.NODE_ENV === 'production') {
const postcssOptions =
nuxt.options.postcss || /* nuxt 3 */ /* @ts-ignore */
nuxt.options.build.postcss.postcssOptions || /* older nuxt3 */ /* @ts-ignore */
nuxt.options.build.postcss as any
postcssOptions.plugins = postcssOptions.plugins || {}
postcssOptions.plugins.cssnano = postcssOptions.plugins.cssnano ?? {}
postcssOptions.plugins.cssnano.preset = postcssOptions.plugins.cssnano.preset ?? []
postcssOptions.plugins.cssnano.preset = [
'default', {
...(postcssOptions.plugins.cssnano.preset[1] || {}),

Check warning on line 141 in src/module.ts

View check run for this annotation

Codecov / codecov/patch

src/module.ts#L132-L141

Added lines #L132 - L141 were not covered by tests
discardComments: { removeAll: true }
}]
}

Check warning on line 144 in src/module.ts

View check run for this annotation

Codecov / codecov/patch

src/module.ts#L143-L144

Added lines #L143 - L144 were not covered by tests
} catch (e) {
logger.error(e)
}
Expand Down