Guest User

Untitled

a guest
May 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. // this is the rollup plugin that adds babel as a compilation stage.
  2. import babel from 'rollup-plugin-babel';
  3.  
  4. //Convert CommonJS modules to ES6,
  5. // so they can be included in a Rollup bundle
  6. import commonjs from 'rollup-plugin-commonjs'
  7.  
  8. // Locate modules using the Node resolution algorithm,
  9. // for using third party modules in node_modules
  10. import nodeResolve from 'rollup-plugin-node-resolve'
  11.  
  12. // Rollup plugin to minify generated bundle.
  13. import uglify from 'rollup-plugin-uglify'
  14.  
  15. // Replace strings in files while bundling them.
  16. import replace from 'rollup-plugin-replace'
  17.  
  18. // Serve your rolled up bundle like webpack-dev-server
  19. // without hot reload
  20. import serve from 'rollup-plugin-serve'
  21.  
  22. // this will refresh the browser when detect changes in bundle.
  23. import livereload from 'rollup-plugin-livereload'
  24.  
  25. // this will create index.html file dynamically
  26. // with the script tag pointing to bundle.
  27. import htmlTemplate from 'rollup-plugin-generate-html-template';
  28.  
  29. // this will insert the styles into style tag in html
  30. import postcss from 'rollup-plugin-postcss';
  31.  
  32.  
  33. var productionConfig =
  34. {
  35. input: './src/index.js',
  36. output: {
  37. file: './dist/bundle.js',
  38. format: 'iife'
  39. },
  40. plugins:
  41. [
  42. postcss({
  43. extensions: [ '.css' ],
  44. }),
  45. babel({
  46. exclude: 'node_modules/**'
  47. }),
  48. nodeResolve({
  49. jsnext: true
  50. }),
  51. commonjs({
  52. include: 'node_modules/**',
  53. namedExports:
  54. {
  55. './node_modules/react/react.js':
  56. [ 'cloneElement', 'createElement', 'PropTypes',
  57. 'Children', 'Component' ],
  58. }
  59. }),
  60. replace({
  61. 'process.env.NODE_ENV': JSON.stringify( 'production' )
  62. }),
  63. uglify({
  64. compress: {
  65. screw_ie8: true,
  66. warnings: false
  67. },
  68. output: {
  69. comments: false
  70. },
  71. sourceMap: false
  72. })
  73.  
  74. ]
  75. }
  76.  
  77. var developmentConfig =
  78. {
  79. input: './src/index.js',
  80. output: {
  81. file: './dist/bundle.js',
  82. format: 'iife'
  83. },
  84. plugins:
  85. [
  86. postcss({
  87. extensions: [ '.css' ],
  88. }),
  89. babel({
  90. exclude: 'node_modules/**'
  91. }),
  92. nodeResolve({
  93. jsnext: true
  94. }),
  95. commonjs({
  96. include: 'node_modules/**',
  97. namedExports:
  98. {
  99. './node_modules/react/react.js':
  100. [ 'cloneElement', 'createElement', 'PropTypes',
  101. 'Children', 'Component' ],
  102. }
  103. }),
  104. replace({
  105. 'process.env.NODE_ENV': JSON.stringify( 'development' )
  106. }),
  107. serve({contentBase: 'dist',
  108. open: true}),
  109. htmlTemplate({
  110. template: 'src/index.html',
  111. target: 'dist/index.html',
  112. }),
  113. livereload({watch: 'dist',})
  114. ]
  115. }
  116.  
  117. export default developmentConfig;
Add Comment
Please, Sign In to add comment