UNPKG

1.9 kBJavaScriptView Raw
1// node-resolve will resolve all the node dependencies
2import resolve from 'rollup-plugin-node-resolve';
3import commonjs from 'rollup-plugin-commonjs';
4import babel from 'rollup-plugin-babel';
5import alias from 'rollup-plugin-alias';
6import replace from 'rollup-plugin-replace';
7import path from 'path';
8import fs from 'fs';
9
10const dependencies = Object.keys(require('./package.json').dependencies)
11const appDirectory = fs.realpathSync(process.cwd());
12const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
13
14export default [
15 {
16 input: 'src/index.js',
17 output: {
18 file: 'dist/bundle.main.js',
19 format: 'umd',
20 name: 'Mirage',
21 globals: {
22 react: 'React',
23 'prop-types': 'PropTypes',
24 'styled-components': 'styled'
25 }
26 },
27 // All the used libs needs to be here
28 external: dependencies,
29 plugins: [
30
31 resolve(),
32 babel({
33 exclude: 'node_modules/**'
34 }),
35 alias({
36 SRC: resolveApp('src'), // Will check for ./bar.jsx and ./bar.js
37 resolve: ['.js', '/index.js'] ,
38 }),
39 commonjs({
40 include: 'node_modules/**',
41 exclude: ['node_modules/react', 'node_modules/react-dom'],
42 namedExports: {
43 // left-hand side can be an absolute path, a path
44 // relative to the current directory, or the name
45 // of a module in node_modules
46 'react-sizeme': [ 'withSize' ]
47 }
48 })
49 ]
50 },
51 {
52 input: 'src/index.js',
53 output: {
54 file: 'dist/bundle.module.js',
55 format: 'cjs'
56 },
57 // All the used libs needs to be here
58 external: dependencies,
59 plugins: [
60 resolve(),
61 babel({
62 exclude: 'node_modules/**'
63 }),
64 alias({
65 SRC: resolveApp('src'), // Will check for ./bar.jsx and ./bar.js
66 resolve: ['.js', '/index.js'] ,
67 }),
68 ]
69 }
70]