3

I am very new to Vue and node and I am trying to insert a global value in my project but to do so I want to put my index.html in a public dir. I first create a project, but the public src was not created, and I can run it with:

$ npm run dev

If I create the public dir and put the index.html into it, I got an fatal error (without any other message) when I run $ npm run dev. So I installed @vue/cli-service with node, by $ npm install --save @vue/cli-service but nothing change, I have also try to find vue.config.js, that is mentioned in this question, but I didn't find it.

(In my package.json there is this dependecies: "@vue/cli-service": "^3.0.0",)

What am I doing wrong? Thank you

PS: What I am trying to do is to use this and add BAse_URL in my index File, but before that, If I put index.html in the public dir I got the error

5
  • Did you create the project via vue create my-project ? Commented Jul 3, 2019 at 10:22
  • I create it with vue init webpack projectname Commented Jul 3, 2019 at 10:45
  • What do you mean by trying to insert a global value ? Is it a global js file, string etc? Commented Jul 3, 2019 at 11:07
  • whats wring with these methods? stackoverflow.com/questions/49314142/… Commented Jul 3, 2019 at 12:17
  • I add the link in the post Commented Jul 3, 2019 at 14:06

1 Answer 1

3

With Vue-CLI 3 and 4 (and up) no index.html is created in the src folder. So if you want to include any file to your project (such as a CSS file or Jquery Library), you can simply import that in App.vue:

import './assets/css/yourstyles.css';

or in one of the styles globally (for CSS files):

<style>
@import './assets/styles/yourstyles.css';
</style>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.