Skip to content

How to configure ~/ alias in webpacker? #24

Answered by ElMassimo
matoni109 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Chris! @matoni109

In order for webpack to resolve ~/ paths you need to configure an alias (comes by default if you are using Vite Ruby).

Here's an example of how to configure an alias in webpacker.

module.exports = {
  resolve: {
    alias: {
      '~': path.resolve(__dirname, '..', '..', 'app/javascript'),

Make sure to adjust the resolve call based on the location of the file, you want ~ to resolve to app/javascript, so that ~/api is resolved to app/javascript/api where the files are located.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@matoni109
Comment options

@ElMassimo
Comment options

Answer selected by ElMassimo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants