google / web-starter-kit

Web Starter Kit - a workflow for multi-device websites
http://developers.google.com/web/starter-kit
Apache License 2.0
18.43k stars 3.02k forks source link

The proper way to include js libraries? #954

Open artshostak opened 6 years ago

artshostak commented 6 years ago

What is the right way to bring in 3rd-party libraries in the build for development and production? Obviously installing the packaged via npm/yarn into the 'node_modules' folder appears to be the first step, but what's the right way to include them? Referencing them in the 'gulpfile.babel.js' file (for main.min.js output) as well as the 'index.html' file (for main.js) seems like the right approach, but usually causes gulp to stutter and return ESLint errors. Can't find any documentation regarding this, would love to know what the accepted method is.

shariqraza commented 6 years ago

Your referencing sounds right

Referencing them in the 'gulpfile.babel.js' file (for main.min.js output) as well as the 'index.html' file (for main.js)

for the ESLint errors, you can choose to ignore the 3rd-party files from linting, here's how:

  1. Create a .eslintignore file at your project root.
  2. add ignore rule for a file e.g: app/scripts/vendor.min.js or entire folders e.g: app/scripts/vendors/*

https://eslint.org/docs/user-guide/configuring#specifying-file-extensions-to-lint