drop hard-coded "app.css" loading #4
Replies: 11 comments
-
@rigor789 it is a major change but i think it would be a good thing. Would that mean that a user can name the "main" css the way he wants? Would it not break the wepback config ? (currently having special handling of the app.css). |
Beta Was this translation helpful? Give feedback.
-
Correct - the developer can put their css in any folder, with any name, as long as the import statement points to the correct path: import "./styles/main.css" |
Beta Was this translation helpful? Give feedback.
This comment was marked as disruptive content.
This comment was marked as disruptive content.
-
@NathanaelA I actually think what is proposed here goes in the direction you want with no app.CSS forced |
Beta Was this translation helpful? Give feedback.
This comment was marked as disruptive content.
This comment was marked as disruptive content.
-
I for one think the bundler was an amazing step forward. And going back to supporting a solution without it would require a lot of work to port and maintain all the steps that are necessary and current done through webpack. And there are a lot of them! |
Beta Was this translation helpful? Give feedback.
This comment was marked as disruptive content.
This comment was marked as disruptive content.
-
@NathanaelA indeeed off topic. For the rest i ll let @rigor789 answer. But i think there were a lot of hard logics in the core just to "hard" load that css. This change makes the Core a lot easier to maintain |
Beta Was this translation helpful? Give feedback.
-
@NathanaelA this change would not affect any of those resources - playground, the default templates etc would still ship that default
No intent to change this, apart from perhaps internal changes how it's handled.
I think this should be discussed in a separate high-level discussion - it's already possible, apart from NS7 now being esm (not going to go into details here)...
This would not be breaking any docs, examples etc. The main drive behind this proposal is cleaning up the bloat in core that's fixated on a hard-coded We could take a less intrusive route, and refactor how core handles css in general. I don't see the need to handle application CSS and additional CSS (from css imports, theme switching etc.) differently like the core currently does. Everything is just CSS - and with your change from ~2 years ago @NathanaelA - we could explicitly use "tagged" css. When loading the With that in mind And again - the point here is not about actually dropping The original idea was to require an explicit import in the entry file (for bundled apps), and I still think that's worth it (for bundled apps) due to the way bundling works - but we can easily make it non-breaking if we only focus on the internals. |
Beta Was this translation helpful? Give feedback.
This comment was marked as disruptive content.
This comment was marked as disruptive content.
-
Hello if I may interject. I think rather than importing css in your app entry file. What if your global css was specified in the // nativescript.config.ts
export default {
id: 'my-app-id',
appPath: 'app',
appResourcesPath: 'App_Resources',
// path to global styles can be added / changed here
css: [ './app/app.css', './styles/some-other-file.scss' ],
android: {
v8Flags: '--expose_gc',
markingMode: 'none'
}
} I'm a big user of NuxtJS and this setup is similar to how they handle global styles (See here). I'm not super familiar with the source code of Nativescript/core (just been poking around a bit), but since this config file is already being imported into the Nativescript app when it's bundled, it would be trivially to import the css with the paths provided here and it helps remove the "special handling" of app.css. Additionally, it would also be trivial to migrate old projects and templates to this method. (ex: templates have I think there are other benefits to specifying the global styles in the config file and they are as follows: Lower Cognitive OverheadDevelopers will naturally look at the Global Style Config StandardizationFrom the current Nativescript docs concerning Application Wide CSS. It looks like each flavor of Nativescript has a different method for changing your global stylesheet: // javascript / typescript
import { Application } from '@nativescript/core'
Application.setCssFileName('style.css')
Application.run({ moduleName: 'main-page' }) // angular
platformNativeScriptDynamic({ bootInExistingPage: false, cssFile: 'style.css' }) There's also not any documentation on how to accomplish this with Vue, React, or Svelte. So would the method be different as well or is there overlap? However by moving global style configuration to the Anyway that's my counter proposal. |
Beta Was this translation helpful? Give feedback.
-
NativeScript currently looks for an
app.css
file and automatically loads it when the app starts.This has been in NativeScript for a long time, before apps were using webpack for bundling.
With webpack - this is no longer necessary, since it can handle any kind of file through the appropriate loaders.
Proposal: drop code that loads the
app.css
and instead require projects to explicitly import it in their entry file:Beta Was this translation helpful? Give feedback.
All reactions