scaleflex/js-cloudimage-responsive

Load javascript plugins via node modules

Closed this issue · 3 comments

Hi, i want to load the js library file from node_modules instead of CDN, but i have a problem, i can't find bundled module in dist directory like CDN, i check that the bundled file are on build directory. Can you give an example how to load the library from node-modules ?
This is tree structure from js-cloudimage-responsive when installed using npm

.
├── blur-hash
│ ├── blurHash
│ │ ├── base83.js
│ │ ├── decode.js
│ │ ├── error.js
│ │ ├── imageDataPolyfill.js
│ │ ├── index.js
│ │ ├── unit8ClampedArrayPolyfill.js
│ │ └── utils.js
│ ├── ci.config.js
│ ├── ci.service.js
│ ├── ci.utils.js
│ ├── index.js
│ └── polyfills
│ └── prepend.polyfill.js
├── common
│ ├── ci.constants.js
│ └── ci.utils.js
├── lazysizes-intersection.js
├── low-preview
│ ├── ci.config.js
│ ├── ci.service.js
│ ├── ci.styles.css
│ ├── ci.utis.js
│ └── index.js
├── plain
│ ├── ci.config.js
│ ├── ci.service.js
│ ├── ci.utils.js
│ └── index.js
└── wp
└── index.js

I hope you can give me an answer. Thanks a lot.

hey @ridwanzal,
you need to read the documentation for how to install using NPM
and how to initialize it

$ npm install --save js-cloudimage-responsive
import 'js-cloudimage-responsive';

new window.CIResponsive({
  token: 'YOUR_TOKEN',
  baseURL: 'BASE_URL' // optional
});

Hi, @amrw-js thanks for your reply,
for project that use es6 structured it's working like charm. I'm concern that, i think you had build/bundled/minified js that we can use directly from js-cloudimage-responsive "build" directory, like from CDN. I think something like this :

<script src="./node_modules/js-cloudimage-responsive/build/js-cloudimage-responsive.min.js">

if that so, maybe i will store it manually for my project then.
Thanks.

Can't make it works with module. The compiler failed because of missing "module" keyword I think...
"Module build failed: Module not found:"
"...contains a reference to the file "js-cloudimage-responsive".
"This file can not be found, please check it for typos or update it if the file got moved."

Did what mentionned in installation docs.
$ yarn add js-cloudimage-responsive

import 'js-cloudimage-responsive';