webpack.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. var webpack = require('webpack');
  2. var isProd = (process.env.NODE_ENV === 'production');
  3. module.exports = [{
  4. node: {fs: 'empty'},
  5. entry: './src/index.js',
  6. devtool: 'source-map',
  7. output: {
  8. path: './dist',
  9. filename: isProd ? 'react-simplemde-editor.min.js' : 'react-simplemde-editor.js',
  10. libraryTarget: 'umd'
  11. },
  12. module: {
  13. loaders: [
  14. {
  15. test: /\.js$/,
  16. exclude: /node_modules/,
  17. loader: "babel",
  18. query: {
  19. presets: ['react', 'es2015']
  20. }
  21. }
  22. ]
  23. }
  24. }, {
  25. node: {fs: 'empty'},
  26. entry: './src/index.js',
  27. devtool: 'source-map',
  28. output: {
  29. path: './dist',
  30. filename: isProd ? 'simplemde-editor.min.js' : 'simplemde-editor.js',
  31. libraryTarget: 'umd'
  32. },
  33. plugins: [
  34. new webpack.ProvidePlugin({
  35. React: "React", react: "React", "window.react": "React", "window.React": "React"
  36. }),
  37. ],
  38. resolve: {
  39. extensions: ['', '.js'],
  40. alias: {
  41. "react": "src/dummyReact.js"
  42. }
  43. },
  44. externals: {
  45. // Use external version of React
  46. react: {
  47. root: 'React',
  48. commonjs2: 'react',
  49. commonjs: 'react',
  50. amd: 'react'
  51. }
  52. },
  53. module: {
  54. noParse: ["react"],
  55. loaders: [
  56. {
  57. test: /\.js$/,
  58. exclude: /node_modules/,
  59. loader: "babel",
  60. query: {
  61. presets: ['react', 'es2015']
  62. }
  63. }
  64. ]
  65. }
  66. }
  67. ];