1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import { dirname } from 'path';
|
7 | const testsPattern = new RegExp(`^/?[^/]+/(tests|test-support)/`);
|
8 |
|
9 | export default class BundleConfig {
|
10 | constructor(private emberApp: any) {}
|
11 |
|
12 |
|
13 |
|
14 | get names() : ReadonlyArray<string> {
|
15 | return Object.freeze(['app', 'tests']);
|
16 | }
|
17 |
|
18 | get types(): ReadonlyArray<string> {
|
19 | return Object.freeze(['js', 'css']);
|
20 | }
|
21 |
|
22 |
|
23 | bundleEntrypoint(name: string, type: string): string | undefined {
|
24 | switch (name) {
|
25 | case 'tests':
|
26 | switch (type) {
|
27 | case 'js':
|
28 | return 'assets/test-support.js';
|
29 | case 'css':
|
30 | return 'assets/test-support.css';
|
31 | }
|
32 | case 'app':
|
33 | switch (type) {
|
34 | case 'js':
|
35 | return this.emberApp.options.outputPaths.vendor.js.replace(/^\//, '');
|
36 | case 'css':
|
37 | return this.emberApp.options.outputPaths.vendor.css.replace(/^\//, '');
|
38 | }
|
39 | }
|
40 | }
|
41 |
|
42 |
|
43 |
|
44 | bundleForPath(path: string): string {
|
45 | if (testsPattern.test(path)) {
|
46 | return 'tests';
|
47 | } else {
|
48 | return 'app';
|
49 | }
|
50 | }
|
51 |
|
52 | get lazyChunkPath() {
|
53 | return dirname(this.bundleEntrypoint(this.names[0], 'js')!);
|
54 | }
|
55 | }
|