-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.ts
133 lines (128 loc) · 3.91 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import { defineConfig } from 'vite';
import { fileURLToPath, URL } from 'node:url';
import { resolve } from 'node:path';
import { generateDefineConfig } from './compat/ember-data-private-build-infra/index';
import {
Addon as AddonConstructor,
compatPath,
nodePath,
emberAppConfig,
App as AppConstructor,
} from './plugins/ember';
import { eDataPackages, internalPackages } from './plugins/ember-vendor';
const projectRoot = import.meta.url;
export default defineConfig(({ mode }) => {
const isProd = mode === 'production';
const isDev = mode === 'development';
const enableSourceMaps = isDev;
const Addon = (name: string) => {
return AddonConstructor(name, mode);
};
const App = () => {
return AppConstructor(mode);
};
return emberAppConfig(
{
build: {
sourcemap: enableSourceMaps,
chunkSizeWarningLimit: 1000,
rollupOptions: isDev
? {
input: {
main: resolve(__dirname, 'index.html'),
nested: resolve(__dirname, 'tests/index.html'),
},
}
: {
treeshake: 'safest',
},
},
server: {
port: 4200,
},
preview: {
port: 4200,
},
},
[
App()
.extendDefineConfig({
ENV_DEBUG: isProd ? false : true,
DEBUG: isProd ? false : true,
ENV_CI: false,
})
.addAlias(`@/tests/`, fileURLToPath(new URL(`./tests/`, projectRoot)))
.addAliases(
localScopes().map((scope) => ({
find: `@/${scope}`,
replacement: fileURLToPath(new URL(`./src/${scope}`, projectRoot)),
}))
),
...internalPackages(mode),
Addon('@ember-data')
.needBabel()
.extendDefineConfig(generateDefineConfig(isProd))
.addAliases(
eDataPackages().map((pkg) => ({
find: `@ember-data/${pkg}`,
replacement: nodePath(`@ember-data/${pkg}/addon`),
}))
)
.addAlias(/^ember-data$/, 'ember-data/addon')
.addAlias(
/^@ember-data\/private-build-infra$/,
compatPath('ember-data-private-build-infra')
),
Addon('ember-notify').needAlias().needBabel({ removeLegacyLayout: true }),
Addon('ember-wormhole').needBabel({ removeLegacyLayout: true }),
Addon('ember-modal-dialog')
.needAlias()
.needBabel({ removeLegacyLayout: true, dropImportSync: true }),
Addon('ember-responsive').needBabel({ removeLegacyLayout: true }),
Addon('ember-bootstrap').needAlias().needBabel(),
Addon('ember-power-select').needBabel(),
Addon('ember-basic-dropdown').needBabel(),
Addon('ember-ref-bucket').needAlias().needBabel(),
Addon('ember-page-title').needBabel(),
Addon('tracked-toolbox').needAlias().needBabel(),
Addon('@ember-decorators/object').needAlias(),
Addon('@ember-decorators/component').needAlias(),
Addon('@ember-decorators/utils').needAlias(),
Addon('ember-concurrency').needAlias(),
Addon('ember-concurrency-decorators').needAlias(),
Addon('ember-inflector').needAlias(),
Addon('ember-modifier').customModuleEntry('ember-modifier/dist'),
Addon('ember-intl').addAlias(
'ember-intl/-private',
nodePath('ember-intl/addon/-private')
),
Addon('ember-simple-auth')
.addNestedAlias(
'use-session-setup-method',
compatPath('ember-simple-auth/use-session-setup-method.ts')
)
.addAlias(
/ember-simple-auth\/(?!(app|addon)\/)(.+)/,
nodePath('ember-simple-auth/addon/$2')
),
]
);
});
function localScopes() {
return [
'addons',
'authenticators',
'models',
'components',
'config',
'controllers',
'helpers',
'initializers',
'instance-initializers',
'modifiers',
'routes',
'services',
'templates',
'utils',
];
}