简体   繁体   中英

Setup babel plugin with Rails 5 webpacker

I'm trying to setup the idx babel plugin from Facebook in a Rails app that uses Webpacker.

https://github.com/facebookincubator/idx

https://github.com/rails/webpacker

How can I do this properly?

Okay I figured this out. Must add it to the babel.js loader.

// config/webpack/loaders/babel.js

module.exports = {
  test: /\.js(\.erb)?$/,
  exclude: /node_modules/,
  loader: 'babel-loader',
  options: {
    plugins: [
      require('babel-plugin-idx'),
    ],
    presets: [
      ['env', { modules: false }]
    ]
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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