admin管理员组文章数量:1296258
I understand that I can generate a source map, but I want to generate the rollup output without minification. Is it possible to do this? I've googled and haven't found anybody asking this question.
I understand that I can generate a source map, but I want to generate the rollup output without minification. Is it possible to do this? I've googled and haven't found anybody asking this question.
Share Improve this question edited Feb 18, 2021 at 2:10 Daniel Kaplan asked Feb 18, 2021 at 2:00 Daniel KaplanDaniel Kaplan 67.5k57 gold badges268 silver badges401 bronze badges 2- doesn't rollup only minify if you use an external minification plugin like terser? – selfagency Commented Feb 18, 2021 at 2:17
- @selfagency the documentation suggests otherwise: there is an option on whether or not to output a source map – Daniel Kaplan Commented Feb 18, 2021 at 2:20
2 Answers
Reset to default 3usually with rollup:
javascript is minified by @rollup/plugin-terser
to disable minifacation of javascript
remove terser()
from the plugins
array in rollup.config.js
by default, CSS is not minified by rollup-plugin-css-only or rollup-plugin-postcss
rollup-plugin-css-only
has no option for minify
css({ output: 'bundle.css' })
rollup-plugin-postcss
has the default option { minimize: false }
postcss({ extract: 'bundle.css' })
other rollup plugins can produce minified CSS, for example rollup-plugin-svelte
as a workaround, to produce pretty CSS, im using the build script
rollup -c && prettier -w public/build/bundle.css
with npm i -D prettier
all of this may be simpler when migrating from rollup
to vite
see also How do I disable minification when running "build" mand in sveltekit?
and sveltejs: Switch existing project from rollup to vite
and awesome-vite
example vite.config.js
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
export default defineConfig({
// use relative paths to asset files
// https://github./vitejs/vite/issues/762
base: './',
plugins: [
svelte(),
],
build: {
// dont minify JS and CSS
minify: false,
rollupOptions: {
output: {
// remove hashes from output paths
// https://github./vitejs/vite/issues/378
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[ext]`
}
}
},
});
First of all, this question (or one similar) was asked here.
It seems that there isn't a way to do it based on that. I don't know what your exact use case for this is, but maybe you can run it through rollup-plugin-esformatter to make your code readable.
本文标签: javascriptCan I tell rollup to not minimize the code it generatesStack Overflow
版权声明:本文标题:javascript - Can I tell rollup to not minimize the code it generates? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741604595a2387900.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论