Webpack: convert rules to TypeScript

This commit is contained in:
Alex Gleason 2022-10-14 15:43:32 -05:00
parent 671210acad
commit b770cbb175
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
12 changed files with 50 additions and 0 deletions

Binary file not shown.

View file

@ -0,0 +1,13 @@
import { resolve } from 'path';
import type { RuleSetRule } from 'webpack';
/** Recompile code.js whenever git changes. */
const rule: RuleSetRule = {
test: resolve(__dirname, '../../app/soapbox/utils/code.js'),
use: {
loader: resolve(__dirname, '../loaders/git-loader.js'),
},
};
export default rule;

Binary file not shown.

23
webpack/rules/index.ts Normal file
View file

@ -0,0 +1,23 @@
import assets from './assets';
import babel from './babel';
import buildConfig from './babel-build-config';
import git from './babel-git';
import css from './css';
import gitRefresh from './git-refresh';
import nodeModules from './node_modules';
import type { RuleSetRule } from 'webpack';
// Webpack loaders are processed in reverse order
// https://webpack.js.org/concepts/loaders/#loader-features
const rules: RuleSetRule[] = [
...assets,
css,
nodeModules,
babel,
git,
gitRefresh,
buildConfig,
];
export default rules;

Binary file not shown.

14
webpack/rules/mark.ts Normal file
View file

@ -0,0 +1,14 @@
import { env } from 'process';
import type { RuleSetRule } from 'webpack';
let rule: RuleSetRule = {};
if (env.NODE_ENV !== 'production') {
rule = {
test: /\.js$/,
loader: 'mark-loader',
};
}
export default rule;