Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

reactjs absolute import

/* 
	Create a jsconfig.json in the root of your project 
    then add the following code snippet.
    
    use replace "src" with "." if you are using NextJS
*/

{
  "compilerOptions": {
    "baseUrl": "src"
  },
  "include": ["src"]
}
Comment

react vite absolute imports

{
  "paths": {
      "@/*": ["src/*"]
    }
  // ...
}


// vite.config.ts
{
  resolve: {
   alias: [{ find: '@', replacement: '/src' }],
  },
  // ...
}

// then you'd import like this
import Image from @assets/image.png
Comment

PREVIOUS NEXT
Code Example
Javascript :: Convert underscore strings to camel Case 
Javascript :: js watch window resize 
Javascript :: detect mobile device 
Javascript :: jquery sum all input values 
Javascript :: how to make sure footer is fixed at bottom of page 
Javascript :: how to create an invite discord.js 
Javascript :: brackets not autocompleting in js file in vscode 
Javascript :: jquery get value by name 
Javascript :: jquery destroy element 
Javascript :: js ask before close chrome 
Javascript :: jQuery.easing[this.easing] is not a function 
Javascript :: node.js socket.io send data with handshake 
Javascript :: index.js vs main.js 
Javascript :: how to get ip address in javascript 
Javascript :: redirect angular 
Javascript :: javascript hasclass 
Javascript :: timer in javascript 
Javascript :: angular serve on different port 
Javascript :: fetch api post req 
Javascript :: npm proxy config 
Javascript :: javascript loop over class 
Javascript :: show div with jquery 
Javascript :: shadowoffset react native constructor 
Javascript :: axios multipart/form-data 
Javascript :: javascript find smallest number in an array 
Javascript :: auto comoplete off in vu js 
Javascript :: chart js y axis integer 
Javascript :: how to change react icon color 
Javascript :: javascript object to json string 
Javascript :: jquery each array object 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =