2

I've just updated my app to Nativescript 6.1 but I'm having this error calling page.addCss:

page.addCssFile('~/themes/' + settings.cssThemeName + '.css');

and I'm not getting this error:

Error: Could not load CSS from ~/themes/white.css: Error: require's first parameter should be string

Could it be a bug? I've tried multiple way to reach the file but I'm always getting the same error

6
  • What's the require line in your css file look like? Commented Sep 5, 2019 at 17:16
  • @IanMacDonald There is no require inside the css file, it's just simple css Commented Sep 5, 2019 at 17:31
  • 1
    Without a require statement webpack may not include the CSS file in the bundle. You will have to adjust the webpack config to include the file in your bundle. Commented Sep 5, 2019 at 17:44
  • Have you updated the webpack plugin and its configs to latest? Commented Sep 5, 2019 at 17:58
  • @Manoj the file is included by webpack, it works with Nativescript 6.0 Commented Sep 5, 2019 at 19:17

1 Answer 1

4

I had the same issue after I upgraded some of the packages.

upgrade all components to the latest version and everything it should be fine.

This is what I currently have and it's working perfectly.

√ Component nativescript has 6.1.0 version and is up to date.

√ Component tns-core-modules has 6.1.0 version and is up to date.

√ Component tns-android has 6.1.0 version and is up to date.

"nativescript-dev-webpack": "^1.2.0",

Don't forget to regenerate the webpack configuration and dependencies with

npm i nativescript-dev-webpack@latest --save-dev ./node_modules/.bin/update-ns-webpack --deps --configs

For more details here is the documentation Nativescript Upgrade Instructions

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.