forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjust.config.ts
132 lines (108 loc) · 4.12 KB
/
just.config.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import { task, series, parallel, condition, option, addResolvePath } from 'just-scripts';
import path from 'path';
import fs from 'fs';
import { babel } from './tasks/babel';
import { clean } from './tasks/clean';
import { copy } from './tasks/copy';
import { jest as jestTask, jestWatch } from './tasks/jest';
import { sass } from './tasks/sass';
import { ts } from './tasks/ts';
import { eslint } from './tasks/eslint';
import { webpack, webpackDevServer } from './tasks/webpack';
import { apiExtractor } from './tasks/api-extractor';
import { lintImports } from './tasks/lint-imports';
import { prettier } from './tasks/prettier';
import { checkForModifiedFiles } from './tasks/check-for-modified-files';
import { generateVersionFiles } from './tasks/generate-version-files';
import { postprocessTask } from './tasks/postprocess';
import { postprocessAmdTask } from './tasks/postprocess-amd';
import { postprocessCommonjsTask } from './tasks/postprocess-commonjs';
import { startStorybookTask, buildStorybookTask } from './tasks/storybook';
import { isConvergedPackage } from './monorepo/index';
import { getJustArgv } from './tasks/argv';
/** Do only the bare minimum setup of options and resolve paths */
function basicPreset() {
// this adds a resolve path for the build tooling deps like TS from the scripts folder
addResolvePath(__dirname);
option('production');
option('webpackConfig', { alias: 'w' });
// Build only commonjs (not other TS variants) but still run other tasks
option('commonjs');
option('cached', { default: false } as any);
option('registry', { default: 'https://registry.npmjs.org' } as any);
option('push', { default: true } as any);
option('package', { alias: 'p' });
}
export function preset() {
basicPreset();
const args = getJustArgv();
task('no-op', () => {}).cached();
task('clean', clean);
task('copy', copy);
task('jest', jestTask);
task('jest-watch', jestWatch);
task('sass', sass);
task('ts:postprocess', postprocessTask());
task('postprocess:amd', postprocessAmdTask);
task('postprocess:commonjs', postprocessCommonjsTask);
task('ts:commonjs', series(ts.commonjs, 'postprocess:commonjs'));
task('ts:esm', ts.esm);
task('ts:amd', series(ts.amd, 'postprocess:amd'));
task('eslint', eslint);
task('ts:commonjs-only', ts.commonjsOnly);
task('webpack', webpack);
task('webpack-dev-server', webpackDevServer(args));
task('api-extractor', apiExtractor());
task('lint-imports', lintImports);
task('prettier', prettier);
task('check-for-modified-files', checkForModifiedFiles);
task('generate-version-files', generateVersionFiles);
task('storybook:start', startStorybookTask());
task('storybook:build', buildStorybookTask());
task('babel:postprocess', babel);
task('ts:compile', () => {
return args.commonjs
? series('ts:commonjs-only')
: parallel(
// Converged packages must always build commonjs because of babel-make-styles transforms
condition('ts:commonjs', () => !args.min || isConvergedPackage()),
'ts:esm',
condition('ts:amd', () => !!args.production && !isConvergedPackage()),
);
});
task('ts', () => {
return series(
'ts:compile',
'ts:postprocess',
condition('babel:postprocess', () => fs.existsSync(path.join(process.cwd(), '.babelrc.json'))),
);
});
task(
'test',
condition('jest', () => fs.existsSync(path.join(process.cwd(), 'jest.config.js'))),
);
task('lint', parallel('lint-imports', 'eslint'));
task('code-style', series('prettier', 'lint'));
task('dev:storybook', series('storybook:start'));
task('dev', series('copy', 'sass', 'webpack-dev-server'));
task('build:node-lib', series('clean', 'copy', 'ts:commonjs-only')).cached();
task(
'build',
series(
'clean',
'copy',
'sass',
'ts',
condition('api-extractor', () => !args.min),
),
).cached();
task(
'bundle',
condition('webpack', () => fs.existsSync(path.join(process.cwd(), 'webpack.config.js'))),
);
}
preset.basic = basicPreset;
if (process.cwd() === __dirname) {
// load the preset if this is being run within the scripts package
preset();
}