[英]Bootstrap & Rails 6 (no webpack) - Default bootstrap javascript not working
[英]Bootstrap JavaScript Is Not Working with WebPack
I am recently working on projects using Webpack , JS and Bootstrap , but suddenly on the project I am currently working on, and despite using the same Webpack and npm configs the bootstrap Javascript stopped working, although It shows in the javascript bundle in the Sources tab在瀏覽器中。
筆記:
這是 GitHub 上的代碼: https://github.com/WeamAdel/webpack-template
Webpack.config.js:
module.exports = {
entry: {
main: "./src/index.js",
home: "./src/assets/js/home.js",
},
output: {
// filename: "assets/js/[name].[fullhash:7].js",
path: path.resolve(__dirname, "build"),
},
devServer: {
port: 9000,
contentBase: path.resolve(__dirname, "build"),
},
module: {
rules: [
//JS
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
},
},
},
// HTML
{
test: /\.html$/i,
loader: "html-loader",
},
//Pug
{
test: /\.pug$/i,
use: ["html-loader", "pug-html-loader"],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.pug",
chunks: ["main", "home"],
}),
new CleanWebpackPlugin(),
],
optimization: {
minimize: true,
minimizer: [
`...`,
new CssMinimizerPlugin(),
],
},
};
index.js
import "jquery";
import "popper.js";
import "bootstrap/dist/js/bootstrap.min";
遇到這個主題,為相同的症狀尋找解決方案。 就我而言,問題是,我安裝了 4.6.0 版引導程序,但復制並粘貼了 5.0 版的代碼片段。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.