insin / nwb

A toolkit for React, Preact, Inferno & vanilla JS apps, React libraries and other npm modules for the web, with no configuration (until you need it)
Other
5.57k stars 331 forks source link

Inject css framework in template html #94

Open ghost opened 8 years ago

ghost commented 8 years ago

I don't know webpack well, I followed this conversation and was able to create a template HTML for me. `webpack: {

plugins: {

  html: {

    template: "template/index.html",

    favicon: "template/favicon.ico"
  }
}

}`

Now I'd like to add MaterializeCss framework in my HTML, but it fails.

I tried using CDN but I constantly get CORS error. I tried to load files from local directory /template but I get 404 not found, because it tries to read from localhost:3000/template/js/materialize.js

How can I add a css link in header and js scripts in body?

Thanks.

lachlanjc commented 8 years ago

In your index.html file (I would recommend deleting the above configuration and instead putting your template html file at src/index.html, unless you truly need something special), add this code:

Right before the closing </head> tag:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css”>

Right before the closing </body>:

<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/js/materialize.min.js"></script>

That should prevent the /template routing issues and CORS error.

Does that help?