我有一些问题与bootstrap 5和NPM.网站设计使用引导和工程,但不是所有的JS(下拉,模态等...),我只是想学习热导入JS BS捆绑没有CDN.有人可以帮助我,请?感谢您的时间
我的步骤:
npm install bootstrap@5.0.0-alpha1
npm install popper.js --save
npm intsall node-sass --save-d
包.json:
{
"name": "xlf",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "./node_modules/.bin/webpack --watch",
"sass": "node-sass --watch src/scss -o dist/css --output-style nested"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bootstrap": "^5.0.0-alpha1",
"popper.js": "^1.16.1"
},
"devDependencies": {
"node-sass": "^5.0.0",
"webpack": "^5.26.0",
"webpack-cli": "^4.5.0"
}
}
网络包配置js
const path = require('path');
module.exports = {
entry: './src/js/app.js',
output: {
path: path.resolve(__dirname, 'dist','js'),
filename: 'app.js',
},
mode: 'production',
module: {
rules:[
{
test: /.(scss|css)$/,
use:
[
{
options: { reloadAll: true },
},
'css-loader',
'sass-loader',
'node-sass'
]
}
]
}
};
src/js/app.js
import 'bootstrap';
src/scss/app.scss
@import '../../node_modules/bootstrap/scss/bootstrap.scss';
1条答案
按热度按时间lf5gs5x21#
通过以下步骤解决:
1.安装beta版本
1.卸载popper.js并安装@popperjs/core
1.在
import 'bootstrap';
之前添加import '@popperjs/core';
谢谢你的帮助Jabaa。