Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

json files do not get copied over in build-react-component #407

@redbmk

Description

@redbmk

This issue is a:

  • Bug report
  • Question / support request

I built a component using nwb new react-component my-component. In a few places in src I have a few .json files, which I can import with import asdf from './asdf.json' and it works just fine when running the demo with yarn start.

However, when I go to build the component with yarn build the .json files are missing from the es and lib folders, so the files fail to import when used elsewhere.

The workaround I found for now is a somewhat messy bash oneliner, which I then added to package.json as a postbuild so it gets run automatically after the build.

find src -name '*.json' | grep -o '/.*' | xargs -I% bash -c 'cp src% es%; cp src% lib%'
diff --git a/package.json b/package.json
index b72d65a..5a20d7e 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
   ],
   "scripts": {
     "build": "nwb build-react-component",
+    "postbuild": "find src -name '*.json' | grep -o '/.*' | xargs -I% bash -c 'cp src% es%; cp src% lib%'",
     "clean": "nwb clean-module && nwb clean-demo",
     "start": "nwb serve-react-demo",
     "test": "nwb test-react",

It would be awesome if I didn't have to do this. Is there a config I missed somewhere, or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions