This package is deprecated and will no longer be supported in future versions of Ruby2JS.
Webpack loader to compile Ruby2JS (.js.rb
) files to JavaScript.
npm install --save-dev @ruby2js/webpack-loader
# or
yarn add -D @ruby2js/webpack-loader
- Visit ruby2js.com for detailed instructions and examples. Users of Ruby on Rails may wish to start with the Rails introduction which describes how to use the rake tasks provided to get up and running quickly.
There are multiple ways to configure webpack (e.g., webpack.config.js
,
command line options, or using the
node interface. Ruby2JS options can be
placed inline within this configuration, or separately in a rb2js.config.rb
file or provided via a RUBY2JS_OPTIONS
environment variable. Examples of
each are provided below:
module.exports = {
entry: "./main.js.rb",
output: {
path: __dirname,
filename: "main.[contenthash].js"
},
resolve: {
extensions: [".rb.js", ".rb"]
},
module: {
rules: [
{
test: /\.js\.rb$/,
use: [
{
loader: '@ruby2js/webpack-loader',
options: {
eslevel: 2021,
filters: ['functions']
}
},
]
},
]
}
}
See Ruby2JS Options docs for a list of available options.
require "ruby2js/filter/functions"
module Ruby2JS
class Loader
def self.options
{eslevel: 2021}
end
end
end
export RUBY2JS_OPTIONS='{"eslevel": 2021, "filters": ["functions"]}'
git clone https://github.com/ruby2js/ruby2js.git
cd ruby2js/packages/webpack-loader
yarn install
yarn prepare-release
yarn test
- Fork it (https://github.com/ruby2js/ruby2js/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
MIT