2022-10-14 20:43:32 +00:00
|
|
|
import { join, resolve } from 'path';
|
2022-01-10 22:25:06 +00:00
|
|
|
|
2022-10-14 20:43:32 +00:00
|
|
|
import { env, settings } from '../configuration';
|
2020-03-27 20:59:38 +00:00
|
|
|
|
2022-10-14 20:43:32 +00:00
|
|
|
import type { RuleSetRule } from 'webpack';
|
|
|
|
|
2022-12-31 01:13:58 +00:00
|
|
|
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
|
|
|
2022-10-14 20:43:32 +00:00
|
|
|
const rule: RuleSetRule = {
|
2022-02-27 00:13:35 +00:00
|
|
|
test: /\.(js|jsx|mjs|ts|tsx)$/,
|
2020-03-27 20:59:38 +00:00
|
|
|
include: [
|
|
|
|
settings.source_path,
|
|
|
|
...settings.resolved_paths,
|
|
|
|
].map(p => resolve(p)),
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [
|
2022-02-27 00:13:35 +00:00
|
|
|
{
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: {
|
|
|
|
// disable type checker - we will use it in fork plugin
|
|
|
|
transpileOnly: true,
|
|
|
|
},
|
|
|
|
},
|
2020-03-27 20:59:38 +00:00
|
|
|
{
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
cacheDirectory: join(settings.cache_path, 'babel-loader'),
|
|
|
|
cacheCompression: env.NODE_ENV === 'production',
|
|
|
|
compact: env.NODE_ENV === 'production',
|
2022-12-31 01:13:58 +00:00
|
|
|
plugins: isDevelopment ? ['react-refresh/babel'] : [],
|
2020-03-27 20:59:38 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2022-10-14 20:43:32 +00:00
|
|
|
|
|
|
|
export default rule;
|