我想将带有jQuery和Popper.js的Bootstrap 4添加到RollupJS。
如何将它们添加到捆绑器中?
我也在使用Svelte汇总模板。
如果我对您的理解正确,那么您正在使用默认的Svelte Rollup模板(可能通过npx degit sveltejs/template
),并且希望在项目中添加对Bootstrap的支持。
如果是这样,那么我认为应该是...
npm i bootstrap
npm i jquery
npm i popper.js
npm i --save-dev rollup-plugin-css-only
在中rollup.config.js
,添加:
import css from 'rollup-plugin-css-only';
在其他进口商品的顶部。另外,在plugins
数组中添加:
plugins: [
...
production && terser(),
css({ output: 'public/build/extra.css'})
],
在以下方面src/main.js
添加导入:
import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.css';
并在其中public/index.html
添加到汇总生成Extra.css的链接:
<link rel='stylesheet' href='/build/extra.css'>
尽管我没有使用jquery或popper.js,但这至少可以通过汇总为我工作。实际上,当我寻找相反的问题时,我发现了这个问题-如何在不使用jquery和popper.js的情况下通过bootstrap使用汇总。
请记住,由于自动重新加载对rollup.config.js的更改不起作用,因此您需要重新启动开发服务器。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句