How do I get decorators working with babel & webpack?

喜你入骨 提交于 2019-12-04 07:36:41
Chalise

After some searching and this SO answer, I was able to get it working without using a .babelrc file.

Install transform-decorators-legacy

npm install --save-dev babel-plugin-transform-decorators-legacy

Include the plugin in webpack.config.js

loaders: [
  {
    test: /\.jsx?$/,
    exclude: /node_modules/,
    loader: 'babel',
    query: {
      plugins: ['transform-decorators-legacy'],
      presets: ['es2015', 'stage-0', 'react']
    }
  }
]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!