soapbox/webpack/rules/babel.ts

36 wiersze
885 B
TypeScript
Czysty Zwykły widok Historia

2022-10-14 20:43:32 +00:00
import { join, resolve } from 'path';
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';
const isDevelopment = process.env.NODE_ENV === 'development';
2022-10-14 20:43:32 +00:00
const rule: RuleSetRule = {
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: [
{
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',
plugins: isDevelopment ? ['react-refresh/babel'] : [],
2020-03-27 20:59:38 +00:00
},
},
],
};
2022-10-14 20:43:32 +00:00
export default rule;