What is this @ in the require? can someone describe?
let bla = require('@/api/blabla');
what is the "@" symbol means in this path?
CodePudding user response:
You are probably talking about the resolve.alias
in Webpack or subpath patterns in Node.js? They often resolve to @
for their src Directory (for example in Vue.js this is used often but is not limited to vue.js).
For example if @
resolves to the src folder in this structure:
my-app/
├─ src/
│ ├─ foo/
│ │ ├─ bar.js
│ ├─ index.js
├─ package.json
Those imports from index.js will be the same:
@/index.js
and./index.js
@/foo/bar.js
and./foo/bar.js
and from bar.js those will be the same:
@/index.js
and../index.js
@/foo/bar.js
and./bar.js
So these operators can help you to navigate in extremely nested directories to find your files.
CodePudding user response:
It depends upon the package name. Some packages like @fastify/helmet will be written as require('@fastify/helmet')