Nwb: How to access static assets from demo index.html

Created on 18 May 2017  路  5Comments  路  Source: insin/nwb

This issue is a:

  • [ ] Bug report
  • [ ] Feature request
  • [x] Question / support request
  • [ ] Other

(using nwb v0.15.8)

Hello,
I'm new with nwb and, first off, great job, it's a great experience creating packages !

I'm trying to make a sandbox for a library of react components. My components will use css and js files that are in other packages, and that I will load with

All 5 comments

nwb uses https://github.com/kevlened/copy-webpack-plugin to copy the contents of public/ to the output folder, which adds the files to be copied to Webpack's in-memory filesystem, which is what's being served by by webpack-dev-middleware when you run the dev server.

As such, anything in public/ should be available under / when running the dev server, so try /my-static-script.js.

Thanks for your very quick reply ! however, this does not sem to work over here

my html file looks like this:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <script src="/my-static-script.js"></script>
  </head>
  <body>
    <div id="demo"></div>
  </body>
</html>

Does the copy of public/ happen the same way for components and apps created with nwb ?

Is there anything specific to add to nwb.config.js to enable it ?

Where should public/ be located:

  • /public/,
  • /demo/public/,
  • or /demo/src/public/ ?

The public folder is copied in demo/dist/ in build-demo.js

but it does not seem to do it in serve-react-demo

maybe I missed something

I've just spotted that we're not creating the CopyPlugin config for serving the demo, only when building it.

I can add this to the next branch, which will be almost ready for release when I finish updating outdated dependencies.

great, thanks :) !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rudfoss picture rudfoss  路  4Comments

loklaan picture loklaan  路  3Comments

lachlanjc picture lachlanjc  路  3Comments

insin picture insin  路  3Comments

empz picture empz  路  4Comments