我将dc和laravel-mix一起使用,但是它没有从节点模块加载scss文件。我尝试了其他一些解决方案,以在mix.sass中提供includepaths,但它们不起作用。
我尝试过webpack.mix.js中的代码
const path = require('path');
let mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css', {
includePaths: ['./node_modules']
});
但是它仍然给我同样的错误
undefined ^ Can't find stylesheet to import. @import "@material/elevation/mixins";
对于Laravel 6,我必须这样做:
npm install --save material-components-web
app.scss:@import "material-components-web/material-components-web";
webpack.mix.js:
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css', {
sassOptions: {
includePaths: ['./node_modules']
}
});
是的,Edmund Sulzanok的回答是正确的,但也添加sassOptions:]
Laravel版本='6.7.0';
我必须升级npm package.json devDependencies
"devDependencies": { ... "cross-env": "^6.0.3", "laravel-mix": "^5.0.1", ..., "resolve-url-loader": "^3.1.1", "sass": "^1.25.0", "sass-loader": "^8.0.2", ... }, "dependencies": { ... "material-components-web": "^4.0.0", ... }
修改package.json后,运行npm install
npm install
您可能会看到过时的软件包
npm outdated
祝你好运