-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Rebuild all assets #15772
Rebuild all assets #15772
Changes from all commits
1b4a7fd
5ccd8f5
1bb8162
3cf4815
1eb9936
49ff4b6
b0cfc3b
5bf9fb0
e88753b
ad30bc8
e70be28
f377d64
fdbd13c
eca1e9c
3a4cfab
d9099da
e5658fe
93109ca
ac0151a
c3d8616
03a3c50
d5de7ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,8 @@ var fs = require("graceful-fs"), | |
util = require('gulp-util'), | ||
postcss = require('gulp-postcss'), | ||
rtl = require('postcss-rtl'), | ||
babel = require('gulp-babel'); | ||
babel = require('gulp-babel'), | ||
sort = require('gulp-sort'); | ||
|
||
// For compat with older versions of Node.js. | ||
require("es6-promise").polyfill(); | ||
|
@@ -108,15 +109,17 @@ function getAssetGroups() { | |
assetGroups.push(assetGroup); | ||
}); | ||
}); | ||
|
||
return assetGroups; | ||
} | ||
|
||
function resolveAssetGroupPaths(assetGroup, assetManifestPath) { | ||
assetGroup.manifestPath = assetManifestPath; | ||
assetGroup.basePath = path.dirname(assetManifestPath); | ||
assetGroup.inputPaths = assetGroup.inputs.map(function (inputPath) { | ||
const inputPaths = assetGroup.inputs.map(function (inputPath) { | ||
return path.resolve(path.join(assetGroup.basePath, inputPath)).replace(/\\/g, '/'); | ||
}); | ||
assetGroup.inputPaths = inputPaths.sort(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is already about hard-coded input paths (right?) we needn't sort them. Or rather, we mustn't sort them, since the manually specified order might matter in the resulting bundle. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually don't think this sort is needed because we sort later after grabbing the files gulp.src. If you want, remove that sort but keep the other and see if we still get the same results. If that does not work, you can re-add it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It works without sorting at all in the gulpfile too (see #15772 (comment)). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it will work without some sort of sort. Because when we use path that contains a star, some tasks may resolve slower than other which cause the concatenation to not be consistent. When you force the sort, this ensures that the files are always concatenated in the same order. This leads to generating the same file over time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and I mean, this is why we need manual sorting, but in the Assets files. The gulpfile needn't know about that. This isn't an ideal solution (the whole assets pipeline is far from ideal), but without fundamentally re There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are three cases of a wildcard lookup in OC that needed the paths manually listed. Until we add any new files in those three folders, we're done. And if we do add new files there, it's about adding that path to the Assets file (i.e. the same as in the other cases where there's no wildcard). I think we can live with that, and I'd prefer this as an interim solution rather than relying on a library that was last updated two major Gulp versions prior. And the Gulp pipeline is already riddled with issues: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll work on a better solution tomorrow. We should support ** instead of dropping the support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 3 places are where it was used and the order matters, ever (since this only affects the OC source). Why do we need anything more complex before we fix this for good and delete this anyway? If we were to keep this process for the foreseeable future then I wouldn't be happy with this either. But I don't see the point in trying to patch a fundamentally outdated system to maybe prevent a 5-second inconvenience in the future if somebody adds new files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Piedone look at the latest comment in this PR. I fixed the issue without having to depend on any new library. change the
update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll move this to your PR. |
||
assetGroup.watchPaths = []; | ||
if (!!assetGroup.watch) { | ||
assetGroup.watchPaths = assetGroup.watch.map(function (watchPath) { | ||
|
@@ -174,6 +177,7 @@ function buildCssPipeline(assetGroup, doConcat, doRebuild) { | |
generateSourceMaps = false; | ||
|
||
var minifiedStream = gulp.src(assetGroup.inputPaths) // Minified output, source mapping completely disabled. | ||
.pipe(sort()) | ||
.pipe(gulpif(!doRebuild, | ||
gulpif(doConcat, | ||
newer(assetGroup.outputPath), | ||
|
@@ -208,6 +212,7 @@ function buildCssPipeline(assetGroup, doConcat, doRebuild) { | |
// Uncomment to copy assets to wwwroot | ||
//.pipe(gulp.dest(assetGroup.webroot)); | ||
var devStream = gulp.src(assetGroup.inputPaths) // Non-minified output, with source mapping | ||
.pipe(sort()) | ||
.pipe(gulpif(!doRebuild, | ||
gulpif(doConcat, | ||
newer(assetGroup.outputPath), | ||
|
@@ -255,8 +260,9 @@ function buildJsPipeline(assetGroup, doConcat, doRebuild) { | |
target: "es5", | ||
}; | ||
|
||
console.log(assetGroup.inputPaths); | ||
// console.log(assetGroup.inputPaths); | ||
return gulp.src(assetGroup.inputPaths) | ||
.pipe(sort()) | ||
.pipe(gulpif(!doRebuild, | ||
gulpif(doConcat, | ||
newer(assetGroup.outputPath), | ||
|
@@ -301,6 +307,8 @@ function buildJsPipeline(assetGroup, doConcat, doRebuild) { | |
function buildCopyPipeline(assetGroup, doRebuild) { | ||
var stream = gulp.src(assetGroup.inputPaths); | ||
|
||
stream = stream.pipe(sort()); | ||
|
||
if (!doRebuild) { | ||
stream = stream.pipe(newer(assetGroup.outputDir)) | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gulp-sort
is unmaintained, with the last release 8 years ago. This is why I went with manual storing under #15735 (and we should have a better long-term solution anyway: #15740).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sorting them manually will work too. The trick is to sort the files after they are resolved.