css assets path is different in npm run start /npm run build

Open
#2,564 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
css, typescript

Research direction

Start with the public reproduction repository and compare npm run start with npm run build served through http-server; consult the linked local-assets documentation for supported asset handling. Verify whether new assets are copied without restarting and whether CSS URLs resolve consistently in both modes. Done means the behavior is corrected or clearly documented for images and fonts.

Written by the indexing model from the issue text.

Description

Feature: Want this? Upvote it!

Stencil version:

 @stencil/core@1.12.2<version>

I'm submitting a:

[ ] bug report
[x ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:

I've created a component project from scratch with npm init stencil, selecting component in the menu

Inside the my-component folder, I've created an assets folder with an image inside
1.- The project is not detecting the new folder and I'm obliged to stop/start the project to get the new files copied into www/build folder (minor issue imho)
2.- on npm run start to reference an asset in css the path is build/assets/opensource.png

now I run a npm run build and with http-server I serve an index.html, the folder in with the images are now is /www/build/assets/opensource.png,

Expected behavior:

1.- Files automatically copied to www/build folder
2.- Provide a way to use css assets independant of the environment

Steps to reproduce:

I provide a public repo with the example:

https://github.com/biaggi/stencil-poc-css

Related code:

// insert any relevant code here

Other information:

This is the documentation I've found about assets in stenciljs

https://stenciljs.com/docs/local-assets

It's relative to assets in jsx but cannot find information about assets in css, are not supported? any reccomendation?

Another use case is when the component is imported as npm package, the route would be in node_modules...

If the file is an image, I can encode it in base64 encode as a workaround, but If is a font... I dont know what I should do with it.

Best regards

Dominant language
TypeScript
Stars
13.1k
Forks
855
Avg merge
4h 7m
Merged PRs (30d)
44

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stenciljs/core

All issues in stenciljs/core

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.