mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 09:03:56 +08:00
3140a4b2ce
Generally follows the same pattern as #22520 There are some changes here, notably it uses the addon's babel settings rather than the app's, and it goes through the same treatment as the rest of the addon code (which may include more than just babel). However, this probably brings us closer to the normal expectations you have around developing addon code, and in any case, does not seem to have any effect on the final output: ``` $ diff dist/assets/markdown-it-bundle.js /tmp/dist-before/assets/markdown-it-bundle.js ```
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
"use strict";
|
|
|
|
const Funnel = require("broccoli-funnel");
|
|
const mergeTrees = require("broccoli-merge-trees");
|
|
const path = require("path");
|
|
|
|
module.exports = {
|
|
name: require("./package").name,
|
|
|
|
// custom method to produce the tree for markdown-it-bundle.js
|
|
// called by ember-cli-build.js in discourse core
|
|
//
|
|
// code in here is only needed by the editor and we do not want them included
|
|
// into the main addon/vendor bundle; instead, it'll be included via a script
|
|
// tag as needed
|
|
treeForMarkdownItBundle() {
|
|
return mergeTrees([this._treeForEngines(), this._treeForMarkdownIt()]);
|
|
},
|
|
|
|
// treat the JS code in /engines like any other JS code in the /addon folder
|
|
_treeForEngines() {
|
|
let enginesTreePath = path.resolve(this.root, "engines");
|
|
let enginesTree = this.treeGenerator(enginesTreePath);
|
|
|
|
// we started at /engines, if we just call treeForAddon, the modules will
|
|
// be under pretty-text/*, but we want pretty-text/engines/*
|
|
let namespacedTree = new Funnel(enginesTree, {
|
|
destDir: "engines",
|
|
});
|
|
|
|
return this.treeForAddon.call(this, namespacedTree);
|
|
},
|
|
|
|
_treeForMarkdownIt() {
|
|
let markdownIt = require.resolve("markdown-it/dist/markdown-it.js");
|
|
|
|
return new Funnel(path.dirname(markdownIt), {
|
|
files: ["markdown-it.js"],
|
|
});
|
|
},
|
|
|
|
isDevelopingAddon() {
|
|
return true;
|
|
},
|
|
};
|