简体   繁体   English

Webpack 加载器错误:Salesforce Lightning Design React App

[英]Webpack loader error: Salesforce Lightning Design React App

I am receiving the following error when trying to run my application with react lightning design尝试使用 React Lightning 设计运行我的应用程序时收到以下错误

./node_modules/@salesforce/design-system-react/components/button/index.jsx 38:20
Module parse failed: Unexpected token (38:20)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|  */
| class Button extends React.Component {
>   static displayName = BUTTON;
| 
|   static propTypes = {

I have configured at webpack.config.js file with the following loader config below:我在 webpack.config.js 文件中配置了以下加载器配置:

loaders: [
            {
                test: /\.jsx?$/,
                loaders: ['babel'],
                include: [
                    path.join(__dirname, 'public/src'),
                    path.join(__dirname, 'node_modules/@salesforce/design-system-react'),
                ]
            },

This is relevant to babel plugins.这与 babel 插件有关。

And to be more specific: @babel/plugin-proposal-class-properties更具体地说:@babel/plugin-proposal-class-properties
https://babeljs.io/docs/en/babel-plugin-proposal-class-properties https://babeljs.io/docs/en/babel-plugin-proposal-class-properties

const babelLoader = {
  loader: 'babel-loader',
  options: {
    babelrc: false,
    presets: [
      ['@babel/preset-env', {
        targets: { browsers: ['>1%', 'not chrome < 59'] }
      }],
      '@babel/preset-react',
    ],
    plugins: [
      '@babel/plugin-proposal-class-properties',
      '@babel/plugin-proposal-object-rest-spread',
      '@babel/plugin-proposal-export-default-from',
      '@babel/plugin-proposal-export-namespace-from',
    ]
  },
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM