![](/img/trans.png)
[英]Why won't my SCSS load even though it's in the webpack.mix.js in my Laravel project that's scaffolded with React.js?
[英]Why won't my .css file show up in the public directory when building webpack.mix.js?
我在.scss
文件中定義了我的webpack.mix.js
文件。 但是,每當我編譯時, .css
文件都不會出現在我的公共目錄中。 我檢查了文件的拼寫和文件路徑三倍,所以這不是問題。
這是我在部署到生產環境時遇到的錯誤:
File plus/public/css/build/partials/live/user-navigation-live.css not defined in asset manifest. (View: /usr/share/nginx/v-1-2021-05-11_10-38/resources/views/layouts/login.blade.php)
這就是它在login.blade.php
中的定義方式
<link href="{{ Cdn::mix('plus/public/css/build/partials/live/user-navigation-live.css') }}" rel="stylesheet">
這是webpack.mix.js
文件中的定義方式:
mix.sass('resources/assets/sass/partials/live/user-navigation-live.scss', 'public/plus/public/css/build/partials/live/');
這是我的構建方式:
npm run dev && composer dump-autoload
這個問題的原因可能是什么?
你的配置看起來如何?
mix.webpackConfig({
module: {
rules: [
{
test:
/\.scss$/,
use: [
{
loader: 'sass-loader',
options: {
// Prefer Dart Sass
implementation: require('sass'),
// See https://github.com/webpack-contrib/sass-loader/issues/804
webpackImporter: false,
sassOptions: {
includePaths: ['./node_modules', './vendor/']
},
}
},
]
}
]
},
});
if (mix.inProduction()) {
mix.version();
}
您必須添加類似上述配置才能使其正常工作。 為什么不使用asset()
助手加載文件? mix()
僅在您有版本控制的文件時才有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.