npm 编译react项目时不断收到css ParserError

oxosxuxt  于 2023-03-23  发布在  React
关注(0)|答案(1)|浏览(121)

我正在编译我的react项目,它在npm start下运行得很好,但是在编译过程中,我得到了以下错误:

npm run build                               

activity-feed@0.1.0 build
> react-app-rewired --openssl-legacy-provider build

Creating an optimized production build...
Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
Browserslist: caniuse-lite is outdated. Please run the following command: `yarn upgrade`
Browserslist: caniuse-lite is outdated. Please run the following command: `yarn upgrade`
Failed to compile.

./src/HubView.scss
ParserError: Syntax Error at line: 1, column 22

**有什么办法可以正确编译我的项目吗?**我的scss文件:

.HubView {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  --margin: 16px;
  margin: var(--margin);
}

.HubView__title {
  grid-column: 1 / span 2;
  font-weight: bold;
  font-size: 32px;
  line-height: 36px;
  letter-spacing: -1.28px;
}

.HubView__section-header {
  grid-column: 1 / span 2;
  padding: 4px 0;
  font-weight: bold;
  font-size: 16px;
  line-height: 24px;
}

.HubView__category-card {
  height: 92px;
  background-size: cover;
  background-position: center right;
  background-repeat: no-repeat;
  border-radius: 4px;
  color: #fff;
  text-decoration: none;
}

.HubView__category-card-title {
  margin: 10px 12px;
  width: 102px;
  font-weight: bold;
  font-size: 18px;
  line-height: 20px;
}

.HubView__gradient-wrapper {
  grid-column: 1 / span 2;
}

.HubView__gradient {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  width: 100vw;
  height: 70vh;
  background-color: var(--color);
  mask: linear-gradient(rgba(0, 0, 0, 0.3), transparent 100%);
  transition: all 0.2s ease-in-out;
}

.HubView__carousel {
  grid-column: 1 / span 2;
}

.HubView__carousel-items-wrapper {
  overflow-x: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin: 0 calc(var(--margin) * -1);

  &::-webkit-scrollbar {
    height: 0;
  }
}

.HubView__carousel-items {
  position: relative;
  padding: 0 var(--margin);
  grid-column: 1 / span 2;
  display: grid;
  grid-auto-flow: column;
  gap: 16px;
  grid-template-columns: repeat(3, 1fr);

  &:after {
    content: '';
    width: var(--margin);
    height: var(--margin);
    margin-left: calc(var(--margin) * -1);
  }

  & > .HubView__glue-card {
    min-width: 155px;
  }
}

.HubView__entity-row {
  grid-column: 1 / span 2;
  margin: -8px calc(var(--margin) * -1);
}

.HubView__glue-navigation-row {
  grid-column: 1 / span 2;
  margin: -8px calc(var(--margin) * -1);
}

.HubView__carousel-title {
  margin: 0 calc(var(--margin) * -1);
}

.HubView__glue-entity-card {
  min-width: 112px;
}

.HubView .HubView {
  grid-column: 1 / span 2;
}

.HubView--no-margin {
  margin: 0;
}

.HubView__find-tertiary-button {
  grid-column: 1 / span 2;
  text-align: center;

  .HubView__find-tertiary-button-button {
    background: none;
    white-space: nowrap;
    padding: 6px 24px;
    border: 1px solid #535353;
    box-sizing: border-box;
    border-radius: 100px;
    font-style: normal;
    font-weight: bold;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #ffffff;
  }
}
yqkkidmi

yqkkidmi1#

最后一个块中缺少父选择器&

.HubView__find-tertiary-button {
    grid-column: 1 / span 2;
    text-align: center;
    &-button {
        background: none;
        white-space: nowrap;
        padding: 6px 24px;
        border: 1px solid #535353;
        box-sizing: border-box;
        border-radius: 100px;
        font-style: normal;
        font-weight: bold;
        font-size: 10px;
        line-height: 16px;
        text-align: center;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: #ffffff;
    }
}

相关问题