I have a couple of js and css files which were custom built and i want to include that into my vue cli3 project. Is there any way to import those files into my project ?
3 Answers
For custom js files, write all your logic in a object and export it at the end of the file :
const customJs = {
/* custom javascript here */
}
export default customJs;
and then import it where you need it as :
import * as customJs from '../path/to/file.js'
For custom css files, you can use @import between the style tags like this:
@import './../node_modules/foo/bar.css';
1 Comment
saibbyweb
Do consider upvoting the answer as well, if it was helpful :)
You can use a pre-processor when creating the project with vue-cli.
Or if you don't need a pre-processor and you are using CSS modules you can go for this route
As for JavaScript it's pretty straight forward if you are on ES2016/ES6 just use the syntax
import tool from 'toolmodulename';
import x from y?