File: rollup.config.js

package info (click to toggle)
node-react-hot-loader 4.13.1%2B~cs12.12.4-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 6,260 kB
  • sloc: javascript: 12,320; sh: 58; makefile: 17
file content (60 lines) | stat: -rw-r--r-- 1,828 bytes parent folder | download
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
/* eslint-disable flowtype/require-valid-file-annotation, no-console, import/extensions */
const { nodeResolve } = require('@rollup/plugin-node-resolve');
const replace = require('@rollup/plugin-replace');
const commonjs = require('@rollup/plugin-commonjs');
const babel = require('@rollup/plugin-babel');
const json = require('@rollup/plugin-json');
const { terser } = require('rollup-plugin-terser');
const pkg = require('./package.json');

const commonPlugins = [
  json(),
  nodeResolve(),
  //babel({ plugins: ['@babel/plugin-external-helpers'] }),
  babel(),
  commonjs({ ignoreGlobal: true }),
];

const getConfig = (input, dist, env) => ({
  input,
  external: ['react-dom', 'react', 'fs', 'path'].concat(Object.keys(pkg.dependencies)),
  plugins: commonPlugins
    .concat(
      env
        ? [
            replace({
              'process.env.NODE_ENV': JSON.stringify(env),
            }),
          ]
        : [],
    )
    .concat(env === 'production' ? [terser()] : []),
  output: [
    {
      file: dist,
      format: 'cjs',
      exports: 'named',
      globals: { react: 'React' },
    },
  ],
});

module.exports = [
  getConfig('src/index.dev.js', 'dist/react-hot-loader.development.js', 'development'),
  getConfig('src/index.prod.js', 'dist/react-hot-loader.production.min.js', 'production'),

  getConfig('src/babel.dev.js', 'dist/babel.development.js', 'development'),
  getConfig('src/babel.prod.js', 'dist/babel.production.min.js', 'production'),

  getConfig('src/webpack/index.js', 'dist/webpack.development.js', 'development'),
  getConfig('src/webpack/index.js', 'dist/webpack.production.min.js', 'production'),

  {
    input: 'src/webpack/webpackTagCommonJSExports.js',
    plugins: [babel()],
    output: {
      file: 'dist/webpackTagCommonJSExports.js',
      format: 'cjs',
    },
  },
];