Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit is happening now. Discover what's next in customer experience.
SOLVED

Static Files in App Builder

Avatar

Level 2

Hi - I have customers-dashboard sample App Builder project. I want to add some custom HTML and PNG files in the project. I have added in "web-src/src" folder but I cannot access the file.
I tried to use different paths like xxx.adobeio-static.net/src/ws.html etc.
Is it even possible to have these extra static HTML etc. files in the project and how I can get to those (HTML) files?

Thank you!

1 Accepted Solution

Avatar

Correct answer by
Employee

Images are imported automatically when referenced from the web-src/index.html file. You can also import them manually using JS e.g. from the web-src/index.js file: 

 

import myImage from '../image.png';

console.log(myImage); // returns image src path

 

Same for html files: 

 

import myHTML from '../file.html';

console.log(myHTML); // returns file.html content

 

If you want to simply copy static files to the dist folder, you can install the plugin https://www.npmjs.com/package/parcel-plugin-static-files-copy, then create a static folder at the root of your project and put all static files in there. They will be automatically copied to the dist folder. 

 

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

Images are imported automatically when referenced from the web-src/index.html file. You can also import them manually using JS e.g. from the web-src/index.js file: 

 

import myImage from '../image.png';

console.log(myImage); // returns image src path

 

Same for html files: 

 

import myHTML from '../file.html';

console.log(myHTML); // returns file.html content

 

If you want to simply copy static files to the dist folder, you can install the plugin https://www.npmjs.com/package/parcel-plugin-static-files-copy, then create a static folder at the root of your project and put all static files in there. They will be automatically copied to the dist folder. 

 

Avatar

Level 2

Thank you very much. I could not make it work using manual "import image from.." but reference from the web-src/index.html and using the parcel-plugin-static-files-copy; both options worked.