Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve frontend-building related Makefile rules #32753

Closed
wants to merge 2 commits into from

Conversation

StCyr
Copy link
Contributor

@StCyr StCyr commented Jun 8, 2022

Currently it's necessary to run npm run sass:icons in addition to make dev-setup and make build-js, to have the icons on your development server.

This PR improves the frontend-building related Makefile rules to make this additional manual action unneeded anymore

Signed-off-by: Cyrille Bollu cyrpub@bollu.be

@StCyr StCyr requested review from skjnldsv and CarlSchwan June 8, 2022 09:48
@StCyr StCyr self-assigned this Jun 8, 2022
@StCyr StCyr force-pushed the enhancement/better-build-of-frontend-code branch from 5298946 to a930fef Compare June 8, 2022 09:49
Makefile Outdated
Comment on lines 19 to 20
watch-js: build-css
npm run watch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
watch-js: build-css
npm run watch
watch-js: build-css
npm run watch &
npm run sass:watch

Should make it possible to watch both at the same time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind though that I don't run the npm run sass commmand because it gives me errors here (see my message on Talk)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've made the requested change

@StCyr StCyr force-pushed the enhancement/better-build-of-frontend-code branch 3 times, most recently from f9c874e to a499a41 Compare June 13, 2022 09:56
@StCyr
Copy link
Contributor Author

StCyr commented Jun 14, 2022

I don't think the drone failure is due to my changes

@skjnldsv
Copy link
Member

skjnldsv commented Jun 14, 2022

I think we should add the sass commands as a postbuild step instead ?
Makefiles are arbitrary and not ideal imho

@StCyr
Copy link
Contributor Author

StCyr commented Jun 20, 2022

I think we should add the sass commands as a postbuild step instead ? Makefiles are arbitrary and not ideal imho

I don't understand your comment :-(

@skjnldsv
Copy link
Member

I don't understand your comment :-(

https://docs.npmjs.com/cli/v8/using-npm/scripts#pre--post-scripts

  "scripts": {
    "build": "NODE_ENV=production webpack --progress --config webpack.prod.js",
    "postbuild": "npm run sass && npm run sass:icons",
    "sass": "sass --load-path core/css core/css/ apps/*/css",
    "sass:icons": "babel-node core/src/icons.js"
  }

@skjnldsv skjnldsv added the 2. developing Work in progress label Jun 21, 2022
@PVince81
Copy link
Member

I've lost quite some time believing this was already merged and kept compiling and trying different node versions.
I should have looked at the exact failure to see that it was always about icons.

Anyway, we should push this forward fast because others might bump into the same issues.

StCyr and others added 2 commits July 22, 2022 19:13
the dist/icons.css file.
Updates the core/src/icons.js script to allow it to run before
'npm run dev', 'npm run build', or 'npm run watch' is run.

Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
@PVince81 PVince81 force-pushed the enhancement/better-build-of-frontend-code branch from a499a41 to f554c33 Compare July 22, 2022 17:15
@PVince81
Copy link
Member

PVince81 commented Jul 22, 2022

I've rebased this and added the post-build step

next up:

  • local test

@PVince81
Copy link
Member

tested locally, while it does run those commands, there's another separate issue: in README we tell people to run "make build-js-production" and now that would include those commands.

however the scss commands are also exploring the non-core apps and displaying errors for me locally, so nothing gets built.
and this happens right at the end of the time-consuming build. should we make it a pre-build step instead ?

I think we should also limit the scss commands to the apps that are part of the core repo.
Otherwise we need to state in the README that for buildling production assets one needs to delete all non-core apps.

Thoughts ?

@PVince81
Copy link
Member

for reference, this is the local output on my setup:

%  npm run sass && npm run sass:icons

> nextcloud@1.0.0 sass
> sass --load-path core/css core/css/ apps/*/css

Error: Undefined mixin.
   ╷
26 │ @include icon-black-white('briefcase', 'calendar', 5);
   │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  apps/calendar/css/icons.scss 26:1  root stylesheet

Error: Undefined variable.
   ╷
38 │         margin-bottom: $grid-height-unit;
   │                        ^^^^^^^^^^^^^^^^^
   ╵
  apps/contacts/css/Properties/Properties.scss 38:18  root stylesheet

Error: Undefined mixin.
  ╷
1 │ @include icon-black-white('deck', 'deck', 1);
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  apps/deck/css/deck.scss 1:1  root stylesheet

Error: Undefined mixin.
  ╷
4 │ @include icon-black-white('deck', 'deck', 1);
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  apps/deck/css/icons.scss 4:1          @import
  apps/deck/css/globalstyles.scss 27:9  root stylesheet

Error: Undefined mixin.
  ╷
4 │ @include icon-black-white('deck', 'deck', 1);
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  apps/deck/css/icons.scss 4:1  root stylesheet

Error: Undefined mixin.
    ╷
308 │ @include icon-black-white('inbox', 'mail', 1);
    │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ╵
  apps/mail/css/mail.scss 308:1  root stylesheet

Error: Undefined variable.
  ╷
1 │ @media only screen and (max-width: $breakpoint-mobile) {
  │                                    ^^^^^^^^^^^^^^^^^^
  ╵
  apps/mail/css/mobile.scss 1:36  root stylesheet
Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div($size, 210) or calc($size / 210)

More info and automated migrator: https://sass-lang.com/d/slash-div

   ╷
68 │             $sizeY: $size / 210 * 297;
   │                     ^^^^^^^^^^^
   ╵
    apps/officeonline/css/admin.scss 68:12  root stylesheet


Error: Undefined mixin.
   ╷
24 │     @include icon-color('folder', 'filetypes', $color-black, 1, true);
   │     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ╵
  apps/photos/css/icons.scss 24:2  root stylesheet

Error: Undefined variable.
   ╷
62 │ @media only screen and (max-width: $breakpoint-mobile) {
   │                                    ^^^^^^^^^^^^^^^^^^
   ╵
  apps/serverinfo/css/style.scss 62:36  root stylesheet

Error: Undefined mixin.
  ╷
1 │ @include icon-black-white('reply', 'spreed', 1);
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  apps/spreed/css/icons.scss 1:1  root stylesheet

Error: Undefined mixin.
  ╷
1 │ @include icon-black-white('reply', 'spreed', 1);
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  apps/spreed/css/icons.scss 1:1         @import
  apps/spreed/css/merged-files.scss 2:9  root stylesheet

Error: Undefined mixin.
  ╷
1 │ @include icon-black-white('reply', 'spreed', 1);
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  apps/spreed/css/icons.scss 1:1                @import
  apps/spreed/css/merged-public-share.scss 2:9  root stylesheet

Error: Undefined mixin.
  ╷
1 │ @include icon-black-white('reply', 'spreed', 1);
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  apps/spreed/css/icons.scss 1:1              @import
  apps/spreed/css/merged-share-auth.scss 2:9  root stylesheet

Error: Undefined mixin.
  ╷
1 │ @include icon-black-white('reply', 'spreed', 1);
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  apps/spreed/css/icons.scss 1:1   @import
  apps/spreed/css/merged.scss 2:9  root stylesheet

Error: Undefined variable.
   ╷
30 │         border-color: $color-error;
   │                       ^^^^^^^^^^^^
   ╵
  apps/spreed/css/settings-admin.scss 30:17  root stylesheet

Error: Undefined variable.
    ╷
131 │     border-color: $color-error;
    │                   ^^^^^^^^^^^^
    ╵
  apps/support/css/support.scss 131:16  root stylesheet

Error: Undefined mixin.
  ╷
1 │ @include icon-black-white('tasks', 'tasks', 1);
  │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  apps/tasks/css/tasks-talk.scss 1:1  root stylesheet

@StCyr
Copy link
Contributor Author

StCyr commented Aug 4, 2022

tested locally, while it does run those commands, there's another separate issue: in README we tell people to run "make build-js-production" and now that would include those commands.

however the scss commands are also exploring the non-core apps and displaying errors for me locally, so nothing gets built. and this happens right at the end of the time-consuming build. should we make it a pre-build step instead ?

I think we should also limit the scss commands to the apps that are part of the core repo. Otherwise we need to state in the README that for buildling production assets one needs to delete all non-core apps.

Thoughts ?

Ah, maybe you've find out why this command has never been included in the building scripts in the first place; It looks quite difficult to solve efficiently (ie: maintaining a list of core apps).

If we are to update the README file, I would prefer to remove the command from the build script altogether and update the README file with something along the line:

--- a/README.md
+++ b/README.md
@@ -74,6 +74,9 @@ make watch-js
 
 # build for production with minification
 make build-js-production
+
+# build icons (caution: will also try to build icons for non-core apps)
+make icons

And create the corresponding Makefile rule.

@skjnldsv
Copy link
Member

skjnldsv commented Aug 10, 2022

for reference, this is the local output on my setup:

Yes, because you are cloning foreign apps into your server/apps folder
Use apps2 or use a clean server repo :)

@PVince81
Copy link
Member

for reference, this is the local output on my setup:

Yes, because you are cloning foreign apps into your server/apps folder Use apps2 or use a clean server repo :)

yes, I've switched to "apps-extra" since, maybe need to add a note about this in the README so other people don't get surprised

@PVince81
Copy link
Member

PVince81 commented Dec 6, 2022

closing in favor of #35622 which uses pure npm approach of post-build

@PVince81 PVince81 closed this Dec 6, 2022
@skjnldsv skjnldsv deleted the enhancement/better-build-of-frontend-code branch December 6, 2022 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants