Guest User

Untitled

a guest
Jan 17th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. module.exports = {
  2. devServer: {
  3. historyApiFallback: true
  4. },
  5. entry: {
  6. app:"./src/index.js",
  7. vendor: [
  8. "axios",
  9. "react",
  10. "react-dom",
  11. "react-redux",
  12. "react-router",
  13. "react-router-dom",
  14. "redux"
  15. ]
  16. },
  17. output: {
  18. path: __dirname + '/public/views',
  19. filename: '[name].js',
  20. chunkFilename: '[chunkhash].chunk.js',
  21. publicPath: "/views/"
  22. },
  23. module: {
  24. loaders: [
  25. {
  26. test: /.js$/,
  27. loader: "babel-loader",
  28. exclude: [/node_modules/, /pdfmake.js$/]
  29. },
  30. {
  31. test: /.json$/,
  32. loader: "json-loader"
  33. }
  34. ]
  35. },
  36. plugins: [
  37. new webpack.optimize.CommonsChunkPlugin({
  38. name: "vendor",
  39. minChunks: Infinity
  40. }),
  41. new webpack.NamedModulesPlugin(),
  42. new HtmlWebpackPlugin({
  43. filename: __dirname + "/views/index.ejs",
  44. template: __dirname + "/views/template.ejs",
  45. inject: 'body',
  46. chunks: ['vendor', 'app'],
  47. chunksSortMode: 'manual'
  48. }),
  49. new PreloadWebpackPlugin({
  50. rel: "preload",
  51. include: ["vendor", "app"]
  52. }),
  53. new webpack.optimize.OccurrenceOrderPlugin(),
  54. ]
  55. };
  56.  
  57. import React from "react";
  58. import ReactDOM from "react-dom";
  59. import { Provider } from "react-redux";
  60. import { createStore, applyMiddleware } from "redux";
  61. import { BrowserRouter, Route, Switch } from "react-router-dom";
  62.  
  63. import promise from "redux-promise";
  64. import reducers from "./reducers";
  65. import AppInit from "./containers/appInit";
  66.  
  67.  
  68.  
  69. import ProfRegisteringModal from "./containers/modals/register_prof_explanation_modal";
  70.  
  71. const createStoreWithMiddleware = applyMiddleware(promise)(createStore);
  72.  
  73. function errorLoading(err) {
  74. console.error("Dynamic page loading failed", err);
  75. }
  76.  
  77. function loadRoute(cb) {
  78. return module => cb(null, module.default);
  79. }
  80.  
  81. console.log("testst");
  82.  
  83. ReactDOM.render(
  84. <Provider store={createStoreWithMiddleware(reducers)}>
  85. <AppInit>
  86. <BrowserRouter>
  87. <div style={{ height: "100%" }}>
  88. <ProfRegisteringModal />
  89. <Switch>
  90. <Route
  91. path="/inscription/:user"
  92. getComponent={(location, callback) => {
  93. import(
  94. "./components/registering/registering_landing_page.js"
  95. )
  96. .then(loadRoute(cb))
  97. .catch(errorLoading);
  98. }}
  99. />
  100. <Route
  101. path="/inscription"
  102. getComponent={(location, callback) => {
  103. import(
  104. "./components/registering/registering_landing_page.js"
  105. )
  106. .then(loadRoute(cb))
  107. .catch(errorLoading);
  108. }}
  109. />
  110. <Route
  111. path="/connexion"
  112. getComponent={(location, callback) => {
  113. import("./containers/registering/signing_in.js")
  114. .then(loadRoute(cb))
  115. .catch(errorLoading);
  116. }}
  117. />
  118. <Route
  119. path="/equipe"
  120. getComponent={(location, callback) => {
  121. import("./components/team_pres.js")
  122. .then(loadRoute(cb))
  123. .catch(errorLoading);
  124. }}
  125. />
  126. <Route
  127. path="/"
  128. getComponent={(location, callback) => {
  129. import("./containers/app_container.js")
  130. .then(loadRoute(cb))
  131. .catch(errorLoading);
  132. }}
  133. />
  134. </Switch>
  135. </div>
  136. </BrowserRouter>
  137. </AppInit>
  138. </Provider>,
  139. document.querySelector(".root")
  140. );
Add Comment
Please, Sign In to add comment