Consider adding an alias for the generated frontend assets
See original GitHub issueRefactoring a frontend project could be easier if we aliased the generated folder with webpack https://webpack.js.org/configuration/resolve/
That way, you could write
import Company from 'Generated/com/vaadin/tutorial/crm/backend/entity/Company';
instead of
import Company from '../../../../../generated/com/vaadin/tutorial/crm/backend/entity/Company';
Which would also not break if you move the file around.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Consider adding an alias for the generated frontend assets
Consider adding an alias for the generated frontend assets. ... import Company from 'Generated/com/vaadin/tutorial/crm/backend/entity/Company';. instead of
Read more >You can manage aliases for FrontEnd Workflow in one place
Now with the above project config, you can add aliases to your webpack in webpack.config.js as: const aliases = require('alias-hq') ...
Read more >How to resolve aliases in Storybook? - Stack Overflow
Just add this in your .storybook/main.js const path = require('path'); module.exports = { "stories": [ "../components/**/*.stories.mdx", ".
Read more >Robust Frontend Development With Aliases | by Benjamin Todts
To make it understand webpack's aliases, you can add so-called resolvers to this plugin. We will use the eslint-import-resolver-webpack ...
Read more >Using aliases in GraphQL - LogRocket Blog
Keep in mind that with each renaming, you'll need to propagate the new name everywhere in your code. Before adding an alias, you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Tried both the path aliases and the package symlink approaches. The auto-complete and auto-import behaviour in VSCode and IntelliJ IDEA is the same between both approaches, so “IDE support” refers to both of them below.
../../generated/MyEndpoint
@vaadin/generated/MyEndpoint
generated
is moved out offrontend
. Requires FS symlink.Generated/MyEndpoint
Frontend/generated/MyEndpoint
frontend
exports./generated/MyEndpoint
The package alias approach has clear downsides here.
I’d personally prefer aliasing the
Frontend
:import { router } from 'Frontend/index';
@scope-name
.Frontend
alias in generated webpack config for internal use. Adding it totsconfig.json
while implementing this issue would also align aliases in both places, which is nice to have.This is probably a late comment, but just noticed today that NuxtJS is using
~
as the alias to the source root: https://nuxtjs.org/docs/2.x/directory-structure/assets