Posted under Angular & PrimeNG
Permalink
Tags Bug, Gotcha, Tip, Tutorial
Update 23/5/2018
I retried this using Angular 6 and the latest primeng.
Step 2/ below was not needed, and I did not install/reinstall gulp per step 3/ (not used this time – need to check/confirm re this)
The wiki steps referred to below, here, referred to using sass to build the css, but this command did not work for me even when I installed the node.js sass per here - the –update command came back with an error.
I then gave up using sass to compile the sass files.
Because of this issue I still had to fix the theming, so tried to copy the css files as below rather than compile the sass. This time the themes folder was under src\assets\components.
I therefore created another skeleton app, installed primeng using “npm install primeng”, and then copied the themes folder from under node_modules\primeng\resources to src\assets\components, overwriting the themes already there.
This added the css files that were missing.
I could then run the showcase with theming fully working, either using “npm start” or “ng serve” – either worked.
I did notice that the theming borders on the treetable component did not appear to work, but apart from that all the theming including theme switching worked fine.
Original Post
It is useful to have this running locally in order to can try out occasional code hacks on the example code to try out ideas or check how things work if the docs are not clear on a point, knowing that you have started from a working example.
The steps for this basically follow the wiki steps here. Note the following additions/amendments to the steps:-
1/ I cloned the repository from here. Having cloned I then listed and disconnected from the remote repositories, as the clones were just for local use:-
git remote –v
git remote rm origin
git remote –v
2/ Dependencies as follows were added to package.json as per instructions:-
"dependencies": { "@angular/common": "4.0.0", "@angular/compiler": "4.0.0", "@angular/core": "4.0.0", "@angular/forms": "4.0.0", "@angular/http": "4.0.0", "@angular/platform-browser": "4.0.0", "@angular/platform-browser-dynamic": "4.0.0", "@angular/router": "4.0.0", "@angular/animations": "4.0.0", "core-js": "^2.4.1", "rxjs": "^5.2.0", "zone.js": "^0.8.4" },
Following this npm install was run to download all the dependencies
3/ In order to build using gulp as instructed (gulp build), I installed gulp first as per the instructions here:-
npm install --global gulp-clinpm install --save-dev gulp
4/ I then ran npm start to run the showcase, which defaults to http://localhost:8080/
The showcase ran ok locally but there were some issues with the theming – the theme had a transluscent background on the menus and dropdowns for example which did not correctly occlude the text underneath. The live showcase on the PrimeNG site did not have this problem.
On investigation it appears that the theme files are under the main resources/themes directory, but are not being sass compiled from scss during the build so there are no .css files there. The gulp file for the project, gulpfile.js, does not have any entries that do sass compilation so this may be an omission/bug in the version I had downloaded.
The showcase does not use the primeng under node_modules – it defines its own primeng package such that if you try to enter npm install primeng to install the themes in the normal way as part of the npm installed package, you get an error from npm about the duplicate primeng.
My workaround was straightforward – I just copied the theme folder and all subfolders from under the node_modules\primeng\resources directory in another application folder to the projects top level resources directory (in fact I used the primeng-quickstart-webpack which I had already set up) – any other project where you have installed primeng will do. This solved the problem by providing all the css files for the themes, and the themes and theme switching then worked.
As I have no requirement to do a full working build for the showcase this is no problem.
I checked for other posts about theming issues and found a couple of StackOverflow posts about theme issues with Webpack here and here. These may prove relevant for future development.
Leave a Reply
You must be logged in to post a comment.