繁体   English   中英

无法将引导程序与webpack一起使用

[英]Can't use bootstrap with webpack

使用Express,Webpack和Bootstrap。 我正在为样式表使用css-loader 这是我的webpack.config.js

const path = require("path");

config = {
    "entry": "./modules/entry.js",
    "output": {
        "path": path.resolve(__dirname, "public"),
        "filename": "bundle.js"
    },
    "module": {
        "rules": [
            { "test": /\.css$/, "use": "css-loader"}
        ]
    }
}

module.exports = config

Entry.js仅需要样式表:

require("bootstrap")
require("glyphicons")

我将所有这些文件放在我使用app.use(express.static("public"))服务的公用文件夹中

在index.html中,我有一个脚本标记:

<script src="./public/bundle.js" type="text/javascript">

在我的html上使用bootstrap类(或glyphicons)没有任何作用。

尝试使用webpack引导程序

https://github.com/shakacode/bootstrap-loader

require('bootstrap')仅会导入JavaScript,要导入CSS,您需要使用require('bootstrap/dist/css/bootstrap.min.css') ,或者在使用非编译引导版本的情况下,您将需要更多的装载机。

您可以在此处的官方文档页面中找到更多信息和配置示例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM