|
1 | 1 | 'use strict'; |
2 | 2 | const { buildEngine } = require('ember-engines/lib/engine-addon'); |
3 | 3 | const { name } = require('./package'); |
4 | | -const Funnel = require('broccoli-funnel'); |
5 | | - |
6 | | -function isDevServe() { |
7 | | - // env checks |
8 | | - const env = process.env.EMBER_ENV || process.env.NODE_ENV || 'development'; |
9 | | - const isProd = env === 'production' || process.env.CI === 'true'; |
10 | | - |
11 | | - // command-line checks (serve/watch only) |
12 | | - const argv = process.argv.join(' '); |
13 | | - const isServeCmd = /\b(ember|node).* (serve|server)\b/.test(argv) || process.argv.includes('serve') || process.argv.includes('server'); |
14 | | - const isWatch = process.argv.includes('--watch') || process.env.BROCCOLI_WATCHER; |
15 | | - |
16 | | - return !isProd && (isServeCmd || isWatch); |
17 | | -} |
18 | 4 |
|
19 | 5 | module.exports = buildEngine({ |
20 | 6 | name, |
21 | 7 |
|
22 | | - init() { |
23 | | - if (this._super.init) this._super.init.apply(this, arguments); |
24 | | - |
25 | | - if (isDevServe()) { |
26 | | - for (let addon of this.addons || []) { |
27 | | - if (['@fleetbase/ember-core', '@fleetbase/ember-ui'].includes(addon.name)) { |
28 | | - let origTreeFor = addon.treeFor?.bind(addon); |
29 | | - addon.treeFor = function (type) { |
30 | | - if (type === 'styles') { |
31 | | - return undefined; |
32 | | - } |
33 | | - return origTreeFor ? origTreeFor(type) : undefined; |
34 | | - }; |
35 | | - } |
36 | | - } |
37 | | - |
38 | | - const origNonDup = this.nonDuplicatedAddonInvoke?.bind(this); |
39 | | - this.nonDuplicatedAddonInvoke = (hook, args = []) => { |
40 | | - if (hook === 'treeFor' && args[0] === 'styles') { |
41 | | - return []; // prevents dependency style relocation funnel (dev-only) |
42 | | - } |
43 | | - return origNonDup ? origNonDup(hook, args) : []; |
44 | | - }; |
45 | | - } |
46 | | - }, |
47 | | - |
48 | | - postprocessTree(type, tree) { |
49 | | - if (type === 'css') { |
50 | | - tree = new Funnel(tree, { |
51 | | - exclude: ['**/@fleetbase/ember-ui/**/*.css'], |
52 | | - }); |
53 | | - } |
54 | | - |
55 | | - return tree; |
56 | | - }, |
57 | | - |
58 | 8 | lazyLoading: { |
59 | 9 | enabled: true, |
60 | 10 | }, |
|
0 commit comments