Errors in Importing assets folder with static url in React parcel project

I am trying to serverside render a react page using Django. The server-side rendering is working fine for normal react components. The project is using parcel to auto-build javaScript files so that Django could render them. This is the command I am using to compile react to Js.
"scripts": { "watch": "parcel watch src/index.tsx --public-url /assets/" }

I am new to the parcel, So sorry for the poor framing of the problem and/or any wrong terminology.

The problem comes whenever I try to import an assets component in my assets folder into my react components. The import statement in my react code is working fine but I am getting an error in the import statements of the assets folder telling the file path for import is wrong. Here is the below screenshot of the issue.

enter image description here

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>@parcel/core: Failed to resolve 'assets/theme/base/typography' from './src/assets/theme/index.js'
C:profitionalBRAVOServerassetssrcassetsthemeindex.js:23:24
22 | import breakpoints from "assets/theme/base/breakpoints";
> 23 | import typography from "assets/theme/base/typography";
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24 | import boxShadows from "assets/theme/base/boxShadows";
25 | import borders from "assets/theme/base/borders";
Done in 689.72s.
C:profitionalBRAVOServerassets>yarn parcel watch src/index.tsx
yarn run v1.22.19
$ C:profitionalBRAVOServerassetsnode_modules.binparcel watch src/index.tsx
× Build failed.
@parcel/core: Failed to resolve 'assets/theme/base/breakpoints' from './src/assets/theme/index.js'
C:profitionalBRAVOServerassetssrcassetsthemeindex.js:22:25
21 | import colors from "assets/theme/base/colors";
> 22 | import breakpoints from "assets/theme/base/breakpoints";
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23 | import typography from "assets/theme/base/typography";
24 | import boxShadows from "assets/theme/base/boxShadows";
</code>
<code>@parcel/core: Failed to resolve 'assets/theme/base/typography' from './src/assets/theme/index.js' C:profitionalBRAVOServerassetssrcassetsthemeindex.js:23:24 22 | import breakpoints from "assets/theme/base/breakpoints"; > 23 | import typography from "assets/theme/base/typography"; > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | import boxShadows from "assets/theme/base/boxShadows"; 25 | import borders from "assets/theme/base/borders"; Done in 689.72s. C:profitionalBRAVOServerassets>yarn parcel watch src/index.tsx yarn run v1.22.19 $ C:profitionalBRAVOServerassetsnode_modules.binparcel watch src/index.tsx × Build failed. @parcel/core: Failed to resolve 'assets/theme/base/breakpoints' from './src/assets/theme/index.js' C:profitionalBRAVOServerassetssrcassetsthemeindex.js:22:25 21 | import colors from "assets/theme/base/colors"; > 22 | import breakpoints from "assets/theme/base/breakpoints"; > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | import typography from "assets/theme/base/typography"; 24 | import boxShadows from "assets/theme/base/boxShadows"; </code>
@parcel/core: Failed to resolve 'assets/theme/base/typography' from './src/assets/theme/index.js'

  C:profitionalBRAVOServerassetssrcassetsthemeindex.js:23:24
    22 | import breakpoints from "assets/theme/base/breakpoints";
  > 23 | import typography from "assets/theme/base/typography";
  >    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    24 | import boxShadows from "assets/theme/base/boxShadows";
    25 | import borders from "assets/theme/base/borders";

Done in 689.72s.

C:profitionalBRAVOServerassets>yarn parcel watch src/index.tsx
yarn run v1.22.19
$ C:profitionalBRAVOServerassetsnode_modules.binparcel watch src/index.tsx
× Build failed.

@parcel/core: Failed to resolve 'assets/theme/base/breakpoints' from './src/assets/theme/index.js'

  C:profitionalBRAVOServerassetssrcassetsthemeindex.js:22:25
    21 | import colors from "assets/theme/base/colors";
  > 22 | import breakpoints from "assets/theme/base/breakpoints";
  >    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    23 | import typography from "assets/theme/base/typography";
    24 | import boxShadows from "assets/theme/base/boxShadows";

The issue with this is that I am not able to figure out how to adjust the assets files properly in the react parcel project configurations so that I don’t need to change any of the assets paths.

The is my file paths in the project where:

Server is the Django project root folder

  • assets (Has all react code for SSR)
    • src
      • assets(the folder I am trying to import)
        • theme
          -index(file that is causing the error)

enter image description here
enter image description here

The error is not caused by just one asset import, it’s going to be caused by all the import statements in the src/assets folder. I already tried to change all the file paths in the assets folder that are causing the issue but it’s too cumbersome. What can I do to solve this issue in this React parcel project?

,parcelrc file

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>{
"extends": ["@parcel/config-default"],
"resolvers": ["@parcel/resolver-glob", "..."]
}
</code>
<code>{ "extends": ["@parcel/config-default"], "resolvers": ["@parcel/resolver-glob", "..."] } </code>
{
  "extends": ["@parcel/config-default"],
  "resolvers": ["@parcel/resolver-glob", "..."]
}

jsconfig.json file

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"*": ["public/src/*"]
}
}
}
</code>
<code>{ "compilerOptions": { "baseUrl": "src", "paths": { "*": ["public/src/*"] } } } </code>
{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "*": ["public/src/*"]
    }
  }
}

Thank you for taking the time to help me with this issue. If you need any additional information please ask in the comments section.

I am expecting to solve this import statment issues by changing the assets folder path in config files so that I don’t have to change all the import statment paths in src/assets folder.

New contributor

Nithin Kamineni is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật