forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv1.ts
More file actions
39 lines (32 loc) · 1.04 KB
/
v1.ts
File metadata and controls
39 lines (32 loc) · 1.04 KB
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
import Preset from '..';
import stylesTranspiler from '../../transpilers/style';
import babelTranspiler from '../../transpilers/babel';
import jsonTranspiler from '../../transpilers/json';
import rawTranspiler from '../../transpilers/raw';
import { aliases, cleanUsingUnmount } from './utils';
export default function initialize() {
const preset = new Preset(
'create-react-app',
['web.js', 'js', 'json', 'web.jsx', 'jsx', 'ts', 'tsx'],
aliases,
{
hasDotEnv: true,
preEvaluate: async manager => {
if (!manager.webpackHMR) {
cleanUsingUnmount(manager);
}
},
}
);
preset.registerTranspiler(module => /\.css$/.test(module.path), [
{ transpiler: stylesTranspiler },
]);
preset.registerTranspiler(module => /\.jsx?$/.test(module.path), [
{ transpiler: babelTranspiler },
]);
preset.registerTranspiler(module => /\.json$/.test(module.path), [
{ transpiler: jsonTranspiler },
]);
preset.registerTranspiler(() => true, [{ transpiler: rawTranspiler }]);
return preset;
}