-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildLoaders.ts
34 lines (27 loc) · 1001 Bytes
/
buildLoaders.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
import webpack from 'webpack';
import { BuildOptions } from './types/config';
import { buildCssLoader } from './loaders/buildСssLoader';
import { buildSvgLoader } from './loaders/buildSvgLoader';
import { buildFileLoader } from './loaders/buildFileLoader';
import { buildBabelLoader } from './loaders/buildBabelLoader';
export function buildLoaders(options: BuildOptions): webpack.RuleSetRule[] {
const { isDev } = options;
const typescriptLoader = {
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
};
const codeBabelLoader = buildBabelLoader({ ...options, isTsx: false });
const tsxCodeBabelLoader = buildBabelLoader({ ...options, isTsx: true });
const svgLoader = buildSvgLoader();
const fileLoader = buildFileLoader();
const cssLoader = buildCssLoader(isDev);
return [
fileLoader,
svgLoader,
codeBabelLoader,
tsxCodeBabelLoader,
// typescriptLoader,
cssLoader,
];
}