简体   繁体   中英

Coffescript 2 output es6 code. Using webpack and coffee-loader, will it automatically transpiled to ES5 code?

Coffescript 2 is out already. It now produces es6 code. Using webpack and coffee-loader, will it automatically be transpiled to ES5 code?

It won't automatically output ES5, no. You either need to use the transpile option in coffee-loader or pipe coffee-loader 's output to a transpiler like Babel.

webpack.config.js per https://github.com/webpack-contrib/coffee-loader#transpile :

module.exports = {
  module: {
    rules: [
      {
        test: /\.coffee$/,
        use: [
          {
            loader: 'coffee-loader',
            options: { 
              transpile: {
                presets: ['env']
              }
            }
          }
        ]
      }
    ]
  }
}

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