Advertisement
Guest User

Untitled

a guest
May 27th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. const path = require("path");
  2. const webpack = require("webpack");
  3. const bundlePath = path.resolve(__dirname, "dist/");
  4.  
  5. module.exports = {
  6. entry: "./src/index.js",
  7. module: {
  8. rules: [
  9. {
  10. test: /.(js|jsx)$/,
  11. exclude: /(node_modules|bower_components)/,
  12. loader: 'babel-loader',
  13. query: { presets: ['react']}
  14. },
  15. {
  16. test: /.css$/,
  17. use: [ 'style-loader', 'css-loader' ]
  18. }
  19. ]
  20. },
  21. resolve: { extensions: ['*', '.js', '.jsx'] },
  22. output: {
  23. publicPath: bundlePath,
  24. filename: "bundle.js"
  25. },
  26. devServer: {
  27. contentBase: path.join(__dirname,'public'),
  28. port: 3000,
  29. publicPath: "http://localhost:3000/dist"
  30. },
  31. plugins: [ new webpack.HotModuleReplacementPlugin() ]
  32. };
  33.  
  34. import React from 'react';
  35. import ReactDOM from 'react-dom';
  36.  
  37. ReactDOM.render(
  38. <h1>Hello, world!</h1>,
  39. document.getElementById('root')
  40. );
  41.  
  42. <!-- sourced from https://raw.githubusercontent.com/reactjs/reactjs.org/master/static/html/single-file-example.html -->
  43. <!DOCTYPE html>
  44. <html>
  45. <head>
  46. <meta charset="UTF-8" />
  47. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  48. <title>React Starter</title>
  49. </head>
  50. <body>
  51. <div id="root"></div>
  52. <noscript>
  53. You need to enable JavaScript to run this app.
  54. </noscript>
  55. <script src="../dist/bundle.js"></script>
  56. </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement