Configure CoffeeScript compilation with Webpacker

This commit is contained in:
Andreas Nedbal 2020-12-25 03:31:46 +01:00 committed by Andreas Nedbal
parent 388d34c9ce
commit df664d2772
3 changed files with 17 additions and 2 deletions

View File

@ -1,3 +1,5 @@
const { environment } = require('@rails/webpacker') const { environment } = require('@rails/webpacker')
const coffee = require('./loaders/coffee')
environment.loaders.prepend('coffee', coffee)
module.exports = environment module.exports = environment

View File

@ -0,0 +1,12 @@
module.exports = {
test: /\.coffee(\.erb)?$/,
use: [{
loader: 'coffee-loader',
options: {
bare: false,
transpile: {
presets: ['@babel/preset-env'],
},
}
}]
}

View File

@ -10,7 +10,7 @@ default: &default
# Additional paths webpack should lookup modules # Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets'] # ['app/assets', 'engine/foo/app/assets']
additional_paths: [] resolved_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs # Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false cache_manifest: false
@ -33,6 +33,7 @@ default: &default
- .woff2 - .woff2
extensions: extensions:
- .coffee
- .mjs - .mjs
- .js - .js
- .sass - .sass
@ -89,4 +90,4 @@ production:
extract_css: true extract_css: true
# Cache manifest.json for performance # Cache manifest.json for performance
cache_manifest: true cache_manifest: true