Skip to content

fix-me/react-library-load-asset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

react-library-load-asset

How do I load a replaceable asset file inside a react component library?

Setup

  1. cd into library and run the commands
    1. npm install
    2. npm run build
    3. npm link
  2. then cd into reactapp and run
    1. npm install
    2. npm link fixme1library
    3. npm start

Challenge

If you look inside the network packets of your browsers developer console F12, you will notice that the 'testFile.yaml' contents got overwritten with the default react index page. So what changes need to be done inside library to get the file loaded properly, without touching reactapps package.json and doing devServer stuff or something similar?

Solution

If you found this, looking for a solution, try rollup: https://medium.com/@kelin2025/so-you-wanna-use-es6-modules-714f48b3a953

For the library run npm run rollup instead of npm run build to test the library build using rollupJS.

Also the rollup-jest-boilerplate might be your friend: https://github.com/algolia/rollup-jest-boilerplate

About

Load a library asset in a react app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published