Webpack和boostrap,从样式标签中删除样式

时间:2018-11-21 18:49:45

标签: css twitter-bootstrap webpack

我是Webpack的新手。使用webpack 4.26。 我正在尝试安装引导程序。我安装了它,但是css样式不是在单独的文件中构建的。我已经解决了这个问题,现在我的配置看起来像这样:

const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
    entry: './app/index.js',
    output: {
        filename: 'app.js',
        path: path.resolve(__dirname, 'dist')
    },
    module: {
        rules: [
            {
                test: /\.(scss)$/,
                use: [
                    MiniCssExtractPlugin.loader,
                    'css-loader',
                    'postcss-loader',
                    'sass-loader'
                ]
            },
            {
                test: /\.(png|svg|jpe?g|gif)$/,
                exclude: /svg[\/\\]/,
                loader: 'file-loader',
                options: {
                    name: 'images/[name].[ext]'
                }
            }
        ]
    },
    plugins: [
        new MiniCssExtractPlugin({
            filename: 'style.css',
        })
    ]
};

Index.js:

'use strict'

import 'bootstrap';
import './index.scss';

index.scss

@import "~bootstrap/scss/bootstrap";

所以现在我有一个单独的文件'style.css',其中包含所有引导程序样式,但是据我所知,样式仍然包含为捆绑并呈现到标记中。 如何将其从捆绑包中删除?

0 个答案:

没有答案