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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parcel not minifying by default even when it says it does #9619

Closed
remino opened this issue Apr 4, 2024 · 2 comments 路 May be fixed by parcel-bundler/website#1106
Closed

Parcel not minifying by default even when it says it does #9619

remino opened this issue Apr 4, 2024 · 2 comments 路 May be fixed by parcel-bundler/website#1106

Comments

@remino
Copy link

remino commented Apr 4, 2024

馃挰 RFC

https://parceljs.org/features/production

By default, minification is enabled when using the parcel build command. You can use the --no-optimize CLI flag to disable minification and other optimizations if needed.

No, it doesn't.

An issue from 2021 clearly state that's also not the case when it is a library.

馃敠 Context

When you're new to Parcel, reading that it does but then seeing it doesn't then trying to figure out why is a waste of time. The text should read:

Except for JavaScript libraries, minification is enabled by default when using the parcel build command. You can use the --no-optimize CLI flag to disable minification and other optimizations if needed.

And examples should be provided on enabling minification.

The issue linked above provides a solution to add the following in your package.json:

{
  "targets": {
    "main": {
      "optimize": true
    }
  }
}

This works for the main, but adding similar rules for the module target doesn't work.

馃捇 Examples

See description above.

@mischnic
Copy link
Member

mischnic commented Apr 5, 2024

This works for me:

{
	"dependencies": {
		"parcel": "^2.12.0"
	},
	"source": "index.js",
	"main": "dist/index.cjs",
	"module": "dist/index.mjs",
	"targets": {
		"main": {
			"optimize": true
		},
		"module": {
			"optimize": true
		}
	},
}

@remino
Copy link
Author

remino commented Apr 5, 2024

@mischnic I dunno what happened in the other package I tried to minify, but this time it worked. Thanks for checking this and updating the docs!

@remino remino closed this as completed Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants