javascript - Webpack : 导入 CSS
问题描述
我的 CSS 有问题。我正在使用这个配置,我想通过在我的脚本中导入 CSS import '@fullcalendar/core/main.css';
。
我有以下错误:
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.
@charset "UTF-8";
| .fc {
| direction: ltr;
@ ./assets/js/admin/admin.js 4:0-37
谢谢你的帮助。
解决方案
下面的配置对我有用
module: {
rules: [{
test: /\.css$/,
use: [
'style-loader',
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
minimize: true,
sourceMap: true
}
}
]
}
]
}
然后在你的js文件中导入这样的东西
import "css/Admin/admin.css";
推荐阅读
- python-3.x - 与 Django 模型中的 postgresql uuid DEFAULT uuid_generate_v4() 有什么相似之处?
- python-3.x - 如何在 Python 中处理大 WAV 文件而不会出现内存错误?
- css - 在 CSS 动画中根据其长度移动文本
- python-3.x - 计算数据框的给定列集中的非零列数 - 熊猫
- angular - Storybook 中的 Angular FormGroup:将圆形结构转换为 JSON
- python - 如何使用python提取xml中的单个特定标签值并修改
- javascript - 如何在从 Django 内置身份验证表单扩展的表单上添加密码切换功能?
- asp.net - 在 ASP.NET MVC 中重复控制表单字段
- redis - 玩家匹配算法(系统设计)
- python - 捕获 Tkinter TreeView 屏幕数据集中列名称更改的问题