北极星shopify导入CSS问题

时间:2018-10-16 14:42:50

标签: javascript reactjs shopify polaris

当我尝试从App.js导入styles.css

import React from 'react';
import {render} from 'react-dom';
import * as PropTypes from 'prop-types';
import {AppProvider, Page, Card, Button} from '@shopify/polaris';
import '@shopify/polaris/styles.css'; // << issue

import SettingsForm from './SettingsForm';

class App extends React.Component { 
static contextTypes = {
  easdk: PropTypes.object,
};

render() { 
  return (
    <AppProvider>
      <Page title="Settings">
        <SettingsForm />
      </Page>
    </AppProvider>
  );
}
}

export default App;

我收到一个错误:编译失败

./node_modules/@shopify/polaris/styles.css (./node_modules/css-loader??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./node_modules/@shopify/polaris/styles.css)
Unclosed bracket (3864:37)

  3862 |     background-color:#c4cdd5;
  3863 |     background-color:var(--progress-upper, #c4cdd5);
> 3864 |     background-image:linear-gradient(to right, transparent 0%, transparent 0%, transparent 100%, transparent 100% transparent;
       |                                     ^
  3865 |     background-image:linear-gradient(to right, var(--progress-lower, transparent) 0%, var(--progress-lower, transparent) var(--Polaris-RangeSlider-progress, 0%), var(--progress-upper, transparent) var(--Polaris-RangeSlider-progress, 100%), var(--progress-upper, transparent) 100%);
  3866 |     border:none;

我验证了node_modules/@shopify/polaris/styles.css中的css与https://sdks.shopifycdn.com/polaris/2.12.1/polaris.css相同

我对此行background-image:linear-gradient(to right, transparent 0%, transparent 0%, transparent 100%, transparent 100% transparent;进行了全局搜索,但结果为0

为什么我在这里遇到错误,请问如何解决? 谢谢。

2 个答案:

答案 0 :(得分:1)

这是一个已知问题

https://github.com/Shopify/polaris/issues/441

升级到最新/下一版本(3.0.0-RC3),就可以了。

答案 1 :(得分:0)

不要在App.js的node_modules中导入css,如果要覆盖node_modules中的某些设置,则应创建一个css或更少的文件,并以css或更少的文件导入css。而且,有很多css @ shopify / polaris / styles.css中的属性,也无需全部导入。