scaleflex / js-cloudimage-responsive

Cloudimage Responsive will smartly resize, compress and accelerate images across the World in your site for all devices. The plugin supports lazy loading technique with fancy animation on image load. Any questions or issues, please report to https://github.com/scaleflex/js-cloudimage-responsive/issues
Other
68 stars 15 forks source link

Load javascript plugins via node modules #23

Closed ridwanzal closed 2 years ago

ridwanzal commented 2 years ago

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.

amrw-js commented 2 years ago

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
});
ridwanzal commented 2 years ago

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.

apsylone commented 11 months ago

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';