vue.js - VueJS:导入的 css 文件显示为内联而不是外部
问题描述
当我在我的入口应用程序文件中包含 css、scss 文件时,系统会将这些 css 文件内容添加为内联 css。但我希望它们编译在一个文件中并像其他 js 文件而不是内联 css 一样自动导入页面。
之前:页面内容是这样的https://prnt.sc/sj2wde。
之后:像这样的东西
<link rel="stylesheet" href="/assets/css/0.styles.7462b628.css">
// Include scss file
import './assets/index.scss';
export function createApp() {
const router = createRouter();
const store = createStore();
sync(store, router);
const app = new Vue({
router,
store,
render: (h) => h(App),
});
return { app, router, store };
}
我尝试使用mini-css-extract-plugin插件,但它仅适用于独立的 vuejs 组件。
//webpack module rule
{
test: /\.css$/,
use: [
isProduction ? MiniCssExtractPlugin.loader : 'vue-style-loader',
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[local]_[hash:base64:8]',
},
},
},
],
}
解决方案
推荐阅读
- python - Pandas - 通过插值填充缺失的经纬度坐标
- python - 特殊字符错误。python pandas和win32com
- authentication - 我的 Joomla 管理员登录页面重定向到自己(无论密码是对还是错)
- excel - 将 VB 脚本 NoShowAttr 转换为 VBA
- plot - 向现有 Dymola 图添加额外的垂直线
- image - 将图像/符号定位在某些单词下方
- java - 如何将对象添加到 Created 类类型的数组?
- r - 复杂的 dplyr group_by 过滤
- sass - 使用 scss 覆盖 bootstrap 4 主按钮样式
- javascript - 我如何从另一个类调用 javascript 类并在数组中推送(追加)值?