Skip to content

Commit bfc9855

Browse files
author
David Pett
committed
fix fastboot styles reloading
1 parent 97d5056 commit bfc9855

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

lib/broccoli/fastboot-config.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var fs = require('fs');
22
var fmt = require('util').format;
33
var uniq = require('lodash.uniq');
4+
var md5Hex = require('md5-hex');
45
var path = require('path');
56
var Plugin = require('broccoli-plugin');
67

@@ -15,6 +16,7 @@ function FastBootConfig(inputNode, options) {
1516
this.fastbootAppConfig = options.fastbootAppConfig;
1617
this.outputPaths = options.outputPaths;
1718
this.appConfig = options.appConfig;
19+
this._fileToChecksumMap = {};
1820
}
1921

2022
FastBootConfig.prototype = Object.create(Plugin.prototype);
@@ -31,7 +33,17 @@ FastBootConfig.prototype.build = function() {
3133
this.buildHostWhitelist();
3234

3335
var outputPath = path.join(this.outputPath, 'package.json');
34-
fs.writeFileSync(outputPath, this.toJSONString());
36+
this.writeFileIfContentChanged(outputPath, this.toJSONString());
37+
};
38+
39+
FastBootConfig.prototype.writeFileIfContentChanged = function(outputPath, content) {
40+
var previous = this._fileToChecksumMap[outputPath];
41+
var next = md5Hex(content);
42+
43+
if (previous !== next) {
44+
fs.writeFileSync(outputPath, content);
45+
this._fileToChecksumMap[outputPath] = next; // update map
46+
}
3547
};
3648

3749
FastBootConfig.prototype.buildDependencies = function() {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"fastboot-filter-initializers": "0.0.2",
7777
"lodash.defaults": "^4.0.1",
7878
"lodash.uniq": "^4.2.0",
79+
"md5-hex": "^1.3.0",
7980
"portfinder": "^1.0.3",
8081
"rsvp": "^3.0.16",
8182
"silent-error": "^1.0.0"

0 commit comments

Comments
 (0)