css - webpack bootstrap-loader 会发出 bootstrap.js 而不是 bootstrap.css 文件?

标签 css twitter-bootstrap webpack sass bootstrap-loader

简而言之,我正在尝试使用 extract-text-webpack-plugin 输出我的 css Assets 。我希望 Bootstrap 加载程序会吐出 bootstrap.css 但事实并非如此。我在想我可能必须在我的 app.js 中添加一个 include 'webpack-loader/path/to/css',但有些东西感觉很俗气和反对webpack 的目的。

下面是我可以创建的代表问题的最小 webpack.config.js。配置假定 webpack.bootstrap.config.js.bootstraprc文件位于与 webpack.config.js

相同的目录中
const path = require("path");

const ExtractTextPlugin = require('extract-text-webpack-plugin');

const bootstrapEntryPoints = require('./webpack.bootstrap.config');

const extractCssPlugin = new ExtractTextPlugin({
    filename : '[name].css'
});

module.exports = {
    entry : {
        app : "./src/js/app.js",
        bootstrap : bootstrapEntryPoints.dev
    },
    output : {
        path : path.resolve(__dirname, 'dist'),
        filename : "[name].bundle.js"
    },
    module : {
        rules : [
            { test: /\.css$/, use : extractCssPlugin.extract({use : [{loader: "css-loader"}]})},
            { test: /\.(woff2?|svg)$/, loader: 'url-loader?limit=10000' },
            { test: /\.(ttf|eot)$/, loader: 'file-loader' },
        ]
    },
    devServer : {
        contentBase : path.join(__dirname, "dist"),
        hot : true,
    },
    plugins : [
        extractCssPlugin,
    ],
};

注意事项:

  • bootstrapEntryPoints.dev 解析为 'bootstrap-loader'。这意味着我的 Bootstrap 入口点看起来像 entry : {..., bootstrap : 'bootstrap-loader'}

最佳答案

解决方案 - 我将 .bootstraprc 中的 extractStyles 变量设置为 true。我现在可以安心休眠了。

关于css - webpack bootstrap-loader 会发出 bootstrap.js 而不是 bootstrap.css 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46634936/

相关文章:

css - Bootstrap 按钮组移动格式重置

node.js - 将 Webpack 添加到现有 React 应用程序

reactjs - React 未在 Webpack 开发服务器上渲染

webpack - Webpack 5 中的 devServer 公共(public)选项

html - dir ="rtl"IE7 输入字段改变焦点位置

html - Div 中的 Twitter Bootstrap 文本超出了其列

jquery - 优化 WordPress 网站中的 jQuery 和 CSS

html - 列背景颜色太多

javascript - 更改 CSS 溢出隐藏行为

css - 鼠标移近时子菜单隐藏