Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const path = require("path");
- const webpack = require("webpack");
- const bundlePath = path.resolve(__dirname, "dist/");
- module.exports = {
- entry: "./src/index.js",
- module: {
- rules: [
- {
- test: /.(js|jsx)$/,
- exclude: /(node_modules|bower_components)/,
- loader: 'babel-loader',
- query: { presets: ['react']}
- },
- {
- test: /.css$/,
- use: [ 'style-loader', 'css-loader' ]
- }
- ]
- },
- resolve: { extensions: ['*', '.js', '.jsx'] },
- output: {
- publicPath: bundlePath,
- filename: "bundle.js"
- },
- devServer: {
- contentBase: path.join(__dirname,'public'),
- port: 3000,
- publicPath: "http://localhost:3000/dist"
- },
- plugins: [ new webpack.HotModuleReplacementPlugin() ]
- };
- import React from 'react';
- import ReactDOM from 'react-dom';
- ReactDOM.render(
- <h1>Hello, world!</h1>,
- document.getElementById('root')
- );
- <!-- sourced from https://raw.githubusercontent.com/reactjs/reactjs.org/master/static/html/single-file-example.html -->
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <title>React Starter</title>
- </head>
- <body>
- <div id="root"></div>
- <noscript>
- You need to enable JavaScript to run this app.
- </noscript>
- <script src="../dist/bundle.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement