在遵循Material Design Top App Bar的scss文档后,我无法使用webpack构建我的scss。我似乎无法在我的scss中包含icon-button.core-styles。IntelliJ还在我的styles. scss上说“无法找到mixin 'core-styles'”。
错误信息
ERROR in ./src/styles.scss
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Undefined mixin.
╷
6 │ @include icon-button.core-styles;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\styles.scss 6:1 root stylesheet
SassError: SassError: Undefined mixin.
╷
6 │ @include icon-button.core-styles;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\styles.scss 6:1 root stylesheet
at Object.loader (D:\...\webpack\node_modules\sass-loader\dist\index.js:69:14)
webpack 5.75.0 compiled with 1 error and 1 warning in 1615 ms
src/styles.scss
@use "@material/icon-button";
@use '@material/top-app-bar/mdc-top-app-bar';
@use "@material/icon-button/styles";
@include icon-button.core-styles;
webpack.config.js
const autoprefixer = require('autoprefixer');
const path = require('path');
module.exports = {
entry: {
// index: './src/_index.ts',
styles: './src/styles.scss',
},
resolve: {
extensions: ['.tsx', '.ts', '.js', 'scss'],
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, './../public/dist'),
clean: true,
},
watch: true,
module: {
rules: [
{
test: /\.scss$/,
use: [
{loader: 'file-loader', options: {name: '[name].css'}},
{loader: 'extract-loader'},
{loader: 'css-loader'},
{loader: 'postcss-loader', options: {postcssOptions: {plugins: [autoprefixer()]}}},
{
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']},
},
}],
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
};
包.json
{
"name": "webpack",
"version": "1.0.0",
"description": "",
"private": true,
"scripts": {
"build": "webpack",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.15.8",
"@babel/preset-env": "^7.15.8",
"autoprefixer": "^10.4.13",
"babel-loader": "^9.1.2",
"css-loader": "^6.7.3",
"extract-loader": "^5.1.0",
"file-loader": "^6.2.0",
"postcss-loader": "^6.2.0",
"sass": "^1.58.0",
"sass-loader": "^12.2.0",
"ts-loader": "^9.2.6",
"typescript": "^4.4.4",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.3.1"
},
"dependencies": {
"@material/icon-button": "^14.0.0",
"@material/top-app-bar": "^14.0.0"
}
}
1条答案
按热度按时间polhcujo1#
这个
应替换为
来源:https://github.com/material-components/material-components-web/issues/6169