-
Notifications
You must be signed in to change notification settings - Fork 640
/
Copy pathember-cli-build.js
133 lines (118 loc) · 3.83 KB
/
ember-cli-build.js
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
'use strict';
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function (defaults) {
let env = EmberApp.env();
let isProd = env === 'production';
let extraPublicTrees = [];
if (!isProd) {
const path = require('node:path');
const funnel = require('broccoli-funnel');
let mswPath = require.resolve('msw/mockServiceWorker.js');
let mswParentPath = path.dirname(mswPath);
extraPublicTrees.push(funnel(mswParentPath, { include: ['mockServiceWorker.js'] }));
}
let browsers = require('./config/targets').browsers;
let app = new EmberApp(defaults, {
'@embroider/macros': {
setConfig: {
'@ember-data/store': {
polyfillUUID: true,
},
},
},
autoImport: {
webpack: {
devtool: isProd ? 'source-map' : 'eval-source-map',
externals: {
// prevent Chart.js from bundling Moment.js
moment: 'moment',
},
},
},
babel: {
plugins: [
require.resolve('ember-auto-import/babel-plugin'),
require.resolve('ember-concurrency/async-arrow-task-transform'),
...require('ember-cli-code-coverage').buildBabelPlugin({ embroider: true }),
],
},
'ember-cli-babel': {
throwUnlessParallelizable: true,
},
cssModules: {
extension: 'module.css',
// see https://github.com/salsify/ember-css-modules/blob/v2.0.1/docs/ORDERING.md
headerModules: [
'crates-io/styles/shared/a11y',
'crates-io/styles/shared/buttons',
'crates-io/styles/shared/forms',
'crates-io/styles/shared/sort-by',
'crates-io/styles/shared/typography',
'crates-io/styles/application',
// for the `.scopes-list` class
'crates-io/styles/settings/tokens/new',
// for the `.box-link` class
'crates-io/components/front-page-list/item',
],
plugins: {
postprocess: [
require('postcss-preset-env')({
browsers,
preserve: false,
features: {
'nesting-rules': true,
},
}),
],
},
},
emberData: {
deprecations: {
DEPRECATE_STORE_EXTENDS_EMBER_OBJECT: false,
},
},
fingerprint: {
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map', 'svg', 'ttf', 'woff', 'woff2'],
},
sourcemaps: {
enabled: true,
extensions: ['js'],
},
});
app.import('node_modules/normalize.css/normalize.css', { prepend: true });
app.import('vendor/qunit.css', { type: 'test' });
const { Webpack } = require('@embroider/webpack');
return require('@embroider/compat').compatBuild(app, Webpack, {
extraPublicTrees,
staticAddonTrees: true,
staticAddonTestSupportTrees: true,
staticModifiers: true,
packagerOptions: {
webpackConfig: {
externals: ({ request, context }, callback) => {
// Prevent `@mswjs/data` from bundling the `msw` package.
//
// `@crates-io/msw` is importing the ESM build of the `msw` package, but
// `@mswjs/data` is trying to import the CJS build instead. This is causing
// a conflict within webpack. Since we don't need the functionality within
// `@mswjs/data` that requires the `msw` package, we can safely ignore this
// import.
if (request == 'msw' && context.includes('@mswjs/data')) {
return callback(null, request, 'global');
}
callback();
},
resolve: {
fallback: {
// disables `crypto` import warning in `axe-core`
crypto: false,
// disables `timers` import warning in `@sinon/fake-timers`
timers: false,
// disables `util` import warning in `@sinon/fake-timers`
util: false,
},
},
},
},
});
};