Comments (4)
I think you probably should not be loading CSS inside of your config/general.php file but:
Vite::$plugin->viteService->entry($path)
from craft-vite.
Here is some context: I am using doublesecretagency/craft-cpcss
plugin to load some custom styling in the control panel, which I generate using Vite. In it's settings I am referencing a custom alias @controlPanelCss
.
In the general.php
file I have this:
use craft\helpers\App;
use nystudio107\vite\Vite;
return [
...
'aliases' => [
...
'@controlPanelCss' => App::env('SITE_URL') . Vite::$plugin->vite->entry('src/js/website-styles.css'),
...
],
...
];
But now I get this error:
Fatal error: Uncaught Error: Typed static property nystudio107\vite\Vite::$plugin must not be accessed before initialization in /var/www/html/cms/config/general.php:15 Stack trace: #0 /var/www/html/cms/vendor/craftcms/cms/src/services/Config.php(277): include() #1 /var/www/html/cms/vendor/craftcms/cms/src/services/Config.php(269): craft\services\Config->_configFromFileInternal('/var/www/html/c...') #2 /var/www/html/cms/vendor/craftcms/cms/bootstrap/bootstrap.php(166): craft\services\Config->getConfigFromFile('general') #3 /var/www/html/cms/vendor/craftcms/cms/bootstrap/web.php(40): require('/var/www/html/c...') #4 /var/www/html/cms/web/index.php(11): require('/var/www/html/c...') #5 {main} thrown in /var/www/html/cms/config/general.php on line 15
Any thoughts?
from craft-vite.
Plugins are not loaded yet when general.php is executed.
I'd suggest just writing a little custom module to load your CSS, ala: https://github.com/nystudio107/craft/blob/craft-vite/cms/modules/sitemodule/src/SiteModule.php#L111
from craft-vite.
Thanks! I will pursue this path.
from craft-vite.
Related Issues (20)
- Error entry does not get injected on twig error HOT 1
- includeCriticalCssTags adds unwanted underscore to critical css file path HOT 2
- [an error occurred while processing the directive] printed on all pages HOT 7
- ValueError: Path cannot be empty HOT 6
- Vite stopped working on MacOS 13.0 Ventura HOT 1
- CORS error (sitename.ddev.site <-> localhost:3000) HOT 1
- 400 Bad Request after starting vite dev HOT 1
- Template named "register" breaks HMR HOT 2
- criticalUrl in .env HOT 3
- Port 3000 now in use by DDEV HOT 1
- Access blocked by CORS: domain.site <> domain.site:3000 HOT 1
- `inline()` function not working with relative local path HOT 2
- craft.vite.asset no longer matches manifest format in Vite 3.x || 4.x HOT 3
- Generic "getHash" helper HOT 1
- Ability to prevent CSS from being extracted from the manifest HOT 1
- Multisite Compatible? HOT 2
- Twigpack::$plugin->manifest->getFileFromManifest() equivalent HOT 4
- Add registerAsset() function so register functionality can work directly with css HOT 1
- Your view on CSS style names coming from Craft's field HOT 2
- Multi-domain setup HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from craft-vite.