vue-cli + webpack: where to include npm package js and css files?

377
July 08, 2017, at 4:00 PM

I'm trying to import an npm package into my vue-cli dev site. Here are the instructions provided by the package website:

It says that it needs the css and js files to be included somewhere in the code. How would I go about doing this?

I'm guessing the css file is included by putting this in App.vue:

<style>
  @import '../node_modules/swiper/dist/css/swiper.min.css';
....
</style>

Is that right? How would I include the .js file? Inside App.vue, or main.js? I'm honestly not sure how the syntax for that would go either.

Here is my index.html file:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="build/swiper.min.css">
  </head>
  <body>
    <div id="app"></div>
    <script src="build/swiper.min.js"></script>
  </body>
</html>
Answer 1

you can include these files in build/index.htmllike common js and css

<head> 
....
 <link rel="stylesheet" href="path_to_css/idangerous.swiper.css">
 <script defer src="path_to_js/idangerous.swiper-2.x.min.js"></script> 
.... 
</head>
READ ALSO
check 2 arrays and see if an ID is in them and then swap out the ID for another and do this for multiple collections

check 2 arrays and see if an ID is in them and then swap out the ID for another and do this for multiple collections

I have a bunch of collections/ models that have useful and notUseful arrays in each documentsThey may contain ids

130
Node.js Unhandled promise rejection

Node.js Unhandled promise rejection

I'm trying to make a login with nodejs using passport but I'm having a problem when a username that's not in the DB tries to login

354
Express.js &amp; Mongoose Query Issue

Express.js & Mongoose Query Issue

I am trying to query my MongoDB for a single document using _idI am using Mongoose (version: 4

261
Table and Chart with Javascript

Table and Chart with Javascript

by using NodeJS or Javascript only, I want to create a simple web page containing a chart and a data table for that chartAfter that, I wanna save the table and chart in a PDF file

250