#30666 closed enhancement (fixed)
Add a comment to RTL and minified files for new contributors
Reported by: | SergeyBiryukov | Owned by: | jorbin |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | needs-patch |
Focuses: | docs | Cc: |
Description
Can we add a small header to RTL and minified files explaining that they are autogenerated and should not be patched directly? This might reduce some confusion for new contributors.
Attachments (4)
Change History (40)
#4
follow-up:
↓ 5
@
10 years ago
What about:
/*! WordPress 4.1.0 - auto-generated on 2014-12-07 8:43:33 PM UTC from filename.ext - please do not patch this file */
#5
in reply to:
↑ 4
;
follow-up:
↓ 6
@
10 years ago
Replying to netweb:
Replying to kpdesign:
That banner should be "static"/hard-coded. Including the date/time in there means the minified file will always change, even when there are no code changes. This triggers unneeded merges/updates downstream.
We had to change that for the concatenated TinyMCE: https://core.trac.wordpress.org/browser/trunk/Gruntfile.js#L376.
#6
in reply to:
↑ 5
@
10 years ago
Replying to azaozz:
That banner should be "static"/hard-coded. Including the date/time in there means the minified file will always change, even when there are no code changes. This triggers unneeded merges/updates downstream.
The three Grunt tasks we'd look to do this with, cssmin
, cssjanus
, and uglify
only compile files into the /build
folder, they never touch files in /src
.
The WordPress packages (nightly, latest etc) are built using the Grunt tools but I don't believe the /build
folder for any of these packages are version controlled, correct me here if I'm wrong. ;)
We could also omit the date/time and just include the version and verbiage requests:
/*! This file was automatically generated as part of the WordPress 4.1.0 release, please see https://make.wordpress.org/core/handbook/... for details on creating patches relating to this file. */
#7
follow-up:
↓ 8
@
10 years ago
I don't believe the /build folder for any of these packages are version controlled
What about https://core.svn.wordpress.org and big sites that use svn/git for deployment. Also that will (probably) trigger new nightly builds even if nothing was changed/committed.
Thinking a short message would be best, not even sure it needs ...as part of the WordPress 4.1.0 release
or - v2.6.0 -
for bbPress.
#8
in reply to:
↑ 7
@
10 years ago
Replying to azaozz:
I don't believe the /build folder for any of these packages are version controlled
What about https://core.svn.wordpress.org and big sites that use svn/git for deployment. Also that will (probably) trigger new nightly builds even if nothing was changed/committed.
Ha, there it is ;)
Thinking a short message would be best, not even sure it needs
...as part of the WordPress 4.1.0 release
or- v2.6.0 -
for bbPress.
I'll think about the bbPress side for a bit (it works as simple plugin version checker for people in the support forums ;))
/*! This is an automatically generated file. */
We could add a link to a handbook page or not, happy for others decisions on this ;)
#10
@
10 years ago
- Keywords has-patch dev-feedback added; needs-patch removed
Patch 30666.diff adds a banner to auto generated CSS & JS files with grunt-banner
https://github.com/mattstyles/grunt-banner.
One of the reasons I went with this option over the way bbPress adds banners is because grunt-contrib-cssmin
has removed banner support in v0.11.0 and would leave us without an upgrade path.
https://github.com/gruntjs/grunt-contrib-cssmin/commit/985b3d8cb60dd45ff9eaa472662ebea69d3b5eb0
Cheers,
Derek
#11
@
10 years ago
- Keywords needs-refresh added; has-patch removed
Thanks Derek, as grunt-contrib-cssmin
is removing banner support I think this is the best way forward, I'd not be surprised if grunt-contrib-uglify
followed suit in the not to distant future and also removed banner support.
A couple of issues on includes and excludes:
usebanner:cssjanus
looks goodusebanner:cssmin
should only add a banner to the files we minify the/wp-admin
files listed here,/wp-includes
looks goodusebanner:uglify
is adding a banner towp-includes/js/zxcvbn.min.js
, your excluding the exclusion ;)usebanner:uglify
should exclude adding banners to TinyMCE JavaScript files, then afterconcat:tinymce
has run, add a single banner to the concatanated build/wp-includes/js/tinymce/wp-tinymce.js` file (Here's what it currently looks like https://cloudup.com/cm8rM4N1lae)
#14
in reply to:
↑ 13
@
10 years ago
Replying to valendesigns:
@netweb - Are the color files in
usebanner:cssmin
ok?
The three you'd expect colors.min.css
, colors-rtl.css
and colors-rtl.min.css
are fine.
That said, each of the four CSS files for each color scheme file are automatically generated by the build tools sourced from each of the colors.scss
files, starting with
sass:colors
generates eachcolors.css
filecssjanus:colors
generates eachcolors-rtl.css
file from thecolors.css
filecssmin:colors
generates bothcolors.min.css
andcolors-rtl.min.css
from their respective non-minified files
So we should add a banner for each of the colors.css
files also :)
#16
@
10 years ago
- Keywords has-patch added; needs-refresh removed
I've refreshed the patch, since the 7 week old one didn't apply cleanly.
#19
@
10 years ago
This duplicates a lot of file paths across tasks. I think there are some things we can do to make this a bit simpler. I normally wouldn't slow down a ticket, but this is a pretty big increase to the maintenance costs of this file.
I would remove "please do not patch" entirely. Someone looking at this file is not likely to be a potential contributor. We shouldn't be implying that you can hack away at the non-auto-gen files as a user. Instead, I'd just go for something simple like /*! This file is automatically generated. */
. If a contributor can't figure out to not patch said file, then I'm not really sure how many more cues we could give them.
When these files are sucked into load-scripts.php and load-styles.php, I surmise there will be repeated "This file is auto generated" throughout. Probably not ideal, though matters little.
#20
@
10 years ago
@nacin I can work on another patch to update the text and and simplify the maintenance aspect by not duplicate the paths. Do you have any suggestions on how you want that to look before I start?
This ticket was mentioned in Slack in #bbpress by netweb. View the logs.
10 years ago
This ticket was mentioned in Slack in #core by drew. View the logs.
10 years ago
#25
@
10 years ago
@valendesigns I just read the logs from last night....
Two things:
cssjanus
has been replaced withrtlcss
via #31332- We need to ensure the Grunt watch tasks still operate as expected which hadn't previously been included included in past patches.
This ticket was mentioned in Slack in #core by drew. View the logs.
10 years ago
#27
@
10 years ago
- Milestone changed from 4.2 to Future Release
I agree with Nacin's comments about both the string and the repetative paths. We should try and reuse filepaths (perhaps going so far as to create a generic file path grouping object so that all file paths are kept in a single place). Simplifying this is beyond trivial, so let's punt it until the next release and we can work on it then.
#28
@
9 years ago
- Owner set to jorbin
- Status changed from new to assigned
@jorbin: Mind taking a second look at whether we want to try to come up with a solution here?
#29
@
9 years ago
I've got a work-in-progress patch for this, it's piggy backing on top of PostCSS using PostCSS Banner, it needs a bit more work and tweaks for paths but the primary issue as it stands is the watch task integration, once I finish up #29792 I'm more than happy to finish this off if no one beats me to it.
#!diff diff --git Gruntfile.js Gruntfile.js index 25069f9..7157716 100644 --- Gruntfile.js +++ Gruntfile.js @@ -45,6 +45,20 @@ module.exports = function(grunt) { src: [ 'wp-admin/css/colors/*/colors.css' ] + }, + banner: { + options: { + processors: [ + require('postcss-banner')({banner: '! This file is automatically generated. '}) + ] + }, + cwd: BUILD_DIR, + dest: BUILD_DIR, + ext: '.min.css', + src: [ + 'wp-admin/css/{<%= cssmin.options["wp-admin"] %>}.css', + 'wp-includes/css/*.css' + ] } }, clean: { diff --git package.json package.json index a2a8fd6..a17d9d8 100644 --- package.json +++ package.json @@ -29,6 +29,7 @@ "grunt-postcss": "~0.5.4", "grunt-rtlcss": "~1.6.0", "grunt-sass": "~1.0.0", - "matchdep": "~0.3.0" + "matchdep": "~0.3.0", + "postcss-banner": "~1.0.0" } }
#30
@
9 years ago
@netweb's solution is on the right track. We need to make sure it covers the following files:
1) All -rtl files
2) All colors files
3) all .min.css files.
As far as wording, I think "This file is build generated" makes a bit more sense than "Automatically generated". Super minor, but it helps people realize that WordPress uses a build system.
#31
@
8 years ago
@netweb Care to followup on @jorbin's feedback in comment:30 here?
In bbPress we add a 'banner' to the each minified CSS and JavaScript file by adding a 'banner' option to the associated Grunt task which results in
e.g.
/*! bbpress - v2.6.0 - 2014-12-07 8:43:33 PM UTC - https://wordpress.org/plugins/bbpress/ */
Any specific verbiage request for the patch? Should we include WordPress version? Timestamp? Links?