Middleman 3 extension adding support for ES6 (via babel-transpiler).
If you use Middleman 4, then there is no need in middleman-es6
extension. To add ES6 support
to Middleman 4 add middleman-sprockets
, sprockets-es6
to Gemfile and configure it to handle
assets with .es6
extension:
# Gemfile
gem 'middleman-sprockets', '~> 4.0.0.rc'
gem 'sprockets-es6'
# config.rb
require 'sprockets/es6'
activate :sprockets do |s|
s.supported_output_extensions << '.es6'
end
If you need Babel's polyfill:
// application.js.es6
//= require babel/polyfill
Add middleman-es6
gem to your application's Gemfile:
gem "middleman-es6", github: "vast/middleman-es6"
Activate it in config.rb
:
activate :es6
Use .es6
as filename extension:
// application.js.es6
let [first, , last] = [1, 2, 3];
class Person {
constructor(name) {
this.name = name;
}
get fullName() {
return `Mr. ${this.name}`;
}
}