shi*_*hin 5 webpack css-loader mini-css-extract-plugin
我正在使用网络包。我需要将 css 文件作为字符串加载,我可以使用 css-loader 来完成此操作,但我还需要使用 MiniCssExtractPlugin 将 css 直接注入到 DOM 中。但是,如果我使用 MiniCssExtractPlugin,当我尝试导入 css 时,我会收到一个空对象。
import bootstrapStyle from 'bootstrap/dist/css/bootstrap.css';
console.log(bootStrapStyle); // empty object
Run Code Online (Sandbox Code Playgroud)
网页包配置
module: {
rules: [{
test: /\.css$/,
use: [{
loader: MiniCssExtractPlugin.loader,
}, {
loader: 'css-loader',
}],
},
Run Code Online (Sandbox Code Playgroud)
有没有办法同时实现两者呢?
我需要将 css 作为字符串,以便将其注入到 Web 组件中。
| 归档时间: |
|
| 查看次数: |
166 次 |
| 最近记录: |