Add js-routes to use Route helpers in JavaScript

This commit is contained in:
Sebastian Serth
2021-07-06 16:54:27 +02:00
parent 9696fcb06f
commit 7914608efe
9 changed files with 49 additions and 0 deletions

View File

@ -7,6 +7,7 @@ github.com/rails/webpacker/blob/master/docs/webpack.md
const { environment } = require('@rails/webpacker')
const { merge } = require('webpack-merge')
const webpack = require('webpack')
const erb = require('./loaders/erb')
// Add an additional plugin of your choosing : ProvidePlugin
environment.plugins.prepend('Provide', new webpack.ProvidePlugin({
@ -24,6 +25,8 @@ environment.plugins.prepend('Provide', new webpack.ProvidePlugin({
})
)
environment.loaders.append('erb', erb)
const envConfig = module.exports = environment
const aliasConfig = module.exports = {
resolve: {

View File

@ -0,0 +1,16 @@
module.exports = {
test: /\.erb$/,
enforce: "pre",
exclude: /node_modules/,
use: [{
loader: "rails-erb-loader",
options: {
runner: (/^win/.test(process.platform) ? "ruby " : "") + "bin/rails runner",
env: {
...process.env,
DISABLE_SPRING: 1,
},
},
}],
}