-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
96 lines (90 loc) · 2.65 KB
/
rollup.config.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
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
import { babel } from '@rollup/plugin-babel';
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import dts from 'rollup-plugin-dts';
import replace from '@rollup/plugin-replace';
import postcss from 'rollup-plugin-postcss';
import postcssDesignTokens from 'postcss-design-tokens';
import autoprefixer from 'autoprefixer';
import simplevars from 'postcss-simple-vars';
import nested from 'postcss-nested';
import cssnext from 'postcss-cssnext';
import cssnano from 'cssnano';
import WDSVariables from '@fandom-frontend/design-system/dist/variables.json';
import { visualizer } from 'rollup-plugin-visualizer';
import analyzer from 'rollup-plugin-analyzer';
import packageJson from './package.json';
const isDev = process.env.NODE_ENV === 'development';
const plugins = [];
const config = [
{
input: {
main: 'src/main.ts',
DesktopArticleVideoLoader: 'src/loaders/DesktopArticleVideoLoader.tsx',
MobileArticleVideoLoader: 'src/loaders/MobileArticleVideoLoader.tsx',
CanonicalVideoLoader: 'src/loaders/CanonicalVideoLoader.tsx',
RedVentureVideoPlayer: 'src/jwplayer/players/RedVentureVideoPlayer/RedVentureVideoPlayer.tsx',
},
output: [
{
dir: 'dist',
compact: false,
plugins: plugins,
format: 'es',
globals: {
react: 'React',
},
},
],
watch: {
include: './src/**',
clearScreen: false,
},
plugins: [
analyzer({
hideDeps: true,
summaryOnly: true,
limit: 0,
}),
replace({
'process.env.NODE_ENV': isDev ? JSON.stringify('development') : JSON.stringify('production'),
__buildDate__: () => JSON.stringify(new Date()),
'process.env.VIDEO_VERSION': JSON.stringify(packageJson.version),
}),
babel({
babelHelpers: 'bundled',
extensions: ['.js', '.jsx', '.es6', '.es', '.mjs', '.ts', '.tsx'],
exclude: ['node_modules', 'src/old', 'src/locales', 'scripts'],
include: ['src/**/*.(ts|tsx|js)'],
}),
typescript({ tsconfig: './tsconfig.json' }),
resolve(),
json(),
commonjs(),
postcss({
modules: true,
minimize: !isDev,
sourceMap: isDev,
extensions: ['.css', '.scss'],
plugins: [
postcssDesignTokens({ tokens: WDSVariables }),
autoprefixer(),
simplevars(),
nested(),
cssnext({ warnForDuplicates: false }),
cssnano(),
],
}),
visualizer(),
],
external: ['react', 'react-dom', 'react-i18next', 'react-i18next', /^@fandom\/tracking-metrics/],
},
{
input: './src/types.d.ts',
output: [{ file: 'dist/main.d.ts', format: 'es' }],
plugins: [dts()],
},
];
export default config;