Maulik Desai
Maulik Desai

Reputation: 43

how to package javascript html and css in one js file

I am trying to implement a chat widget on a website. The chat code has to stay independent of the website. My goal is to make one JS that has everything and Wrap that inside a IIFE. So if someone wants to implement chat on their site he/she can just include one JS and thing would work .

and then user can do window.chat.serverName= Window.chat.start();

This would open a new page and the chat application would be on that

Upvotes: 3

Views: 152

Answers (1)

kaitoy
kaitoy

Reputation: 1675

Use webpack with css-loader and html-loader, and require your css files and html files from javascript. (e.g. const css = require('css/foo.css');)

My project is doing it.

Upvotes: 1

Related Questions