forked from rtk-incubator/rtk-query
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-build.js
42 lines (34 loc) · 899 Bytes
/
post-build.js
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
const fs = require('fs');
const { cp, rm } = require('shelljs');
if (fs.existsSync('dist/esm/ts-4.1')) {
rm('-r', 'dist/esm/ts-4.1');
}
cp('-r', 'dist/esm/ts/', 'dist/esm/ts-4.1');
const stubTs41Types = `
import { EndpointDefinitions } from './endpointDefinitions';
export declare type TS41Hooks<Definitions extends EndpointDefinitions> = unknown;
export {};
`;
fs.writeFileSync('dist/esm/ts/ts41Types.d.ts', stubTs41Types);
fs.writeFileSync(
'dist/index.js',
`
'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./index.cjs.production.min.js')
} else {
module.exports = require('./index.cjs.development.js')
}
`
);
fs.writeFileSync(
'dist/react.js',
`
'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./react.cjs.production.min.js')
} else {
module.exports = require('./react.cjs.development.js')
}
`
);