DEV: Rebuild JS app when files change in discourse-markdown-it (#24379)
Based on a workaround shared in https://github.com/embroider-build/embroider/issues/1635#issue-1935759857
This commit is contained in:
parent
0c712eaa3a
commit
8c16482932
|
@ -14,6 +14,7 @@ const generateWorkboxTree = require("./lib/workbox-tree-builder");
|
|||
const { compatBuild } = require("@embroider/compat");
|
||||
const { Webpack } = require("@embroider/webpack");
|
||||
const { StatsWriterPlugin } = require("webpack-stats-plugin");
|
||||
const withSideWatch = require("./lib/with-side-watch");
|
||||
const RawHandlebarsCompiler = require("discourse-hbr/raw-handlebars-compiler");
|
||||
|
||||
process.env.BROCCOLI_ENABLED_MEMOIZE = true;
|
||||
|
@ -72,10 +73,10 @@ module.exports = function (defaults) {
|
|||
"node_modules/@discourse/backburner.js/dist/named-amd/backburner.js",
|
||||
},
|
||||
|
||||
historySupportMiddleware: false,
|
||||
|
||||
trees: {
|
||||
app: RawHandlebarsCompiler("app"),
|
||||
app: RawHandlebarsCompiler(
|
||||
withSideWatch("app", { watching: ["../discourse-markdown-it"] })
|
||||
),
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
// From https://github.com/cardstack/boxel/blob/d54f834f/packages/host/lib/with-side-watch.js (MIT license)
|
||||
|
||||
const mergeTrees = require("broccoli-merge-trees");
|
||||
const { WatchedDir } = require("broccoli-source");
|
||||
const Plugin = require("broccoli-plugin");
|
||||
|
||||
class BroccoliNoOp extends Plugin {
|
||||
constructor(path) {
|
||||
super([new WatchedDir(path)]);
|
||||
}
|
||||
build() {}
|
||||
}
|
||||
|
||||
/*
|
||||
Doesn't change your actualTree, but causes a rebuild when any of opts.watching
|
||||
trees change.
|
||||
|
||||
This is helpful when your build pipeline doesn't naturally watch some
|
||||
dependencies that you're actively developing. For example, right now
|
||||
@embroider/webpack doesn't rebuild itself when non-ember libraries change.
|
||||
*/
|
||||
module.exports = function withSideWatch(actualTree, opts) {
|
||||
return mergeTrees([
|
||||
actualTree,
|
||||
...opts.watching.map((w) => new BroccoliNoOp(w)),
|
||||
]);
|
||||
};
|
Loading…
Reference in New Issue