Add support for running CodeOcean under a subpath

* Also refactor (JavaScript) routes
This commit is contained in:
Sebastian Serth
2021-07-06 17:02:12 +02:00
parent 7914608efe
commit 237c225732
14 changed files with 40 additions and 28 deletions

View File

@ -4,8 +4,8 @@ Info for this file can be found
github.com/rails/webpacker/blob/master/docs/webpack.md
*/
const { environment } = require('@rails/webpacker')
const { merge } = require('webpack-merge')
const {environment} = require('@rails/webpacker')
const {merge} = require('webpack-merge')
const webpack = require('webpack')
const erb = require('./loaders/erb')
@ -25,6 +25,14 @@ environment.plugins.prepend('Provide', new webpack.ProvidePlugin({
})
)
// This setting will change the absolute path used to refer
// external files (images, fonts, ...) in the generated assets
const relative_url_root = process.env.RAILS_RELATIVE_URL_ROOT || '';
const public_output_path = environment.config.output.publicPath;
environment.loaders.get('file')
.use.find(item => item.loader === 'file-loader')
.options.publicPath = relative_url_root + public_output_path;
environment.loaders.append('erb', erb)
const envConfig = module.exports = environment