Skip to content

Instantly share code, notes, and snippets.

@Bizunow
Last active August 21, 2017 13:49
Show Gist options
  • Save Bizunow/dc3216aa24051da29ced203219492b79 to your computer and use it in GitHub Desktop.
Save Bizunow/dc3216aa24051da29ced203219492b79 to your computer and use it in GitHub Desktop.
[React webpack example] #js #react #webpack
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<title>React App</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
</body>
</html>
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(<h1>Hello</h1>, document.getElementById('root'));
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: './public/index.html',
filename: 'index.html',
inject: 'body'
})
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve('build'),
filename: 'index_bundle.js'
},
module: {
loaders: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.css$/, loader:'style-loader!css-loader', exclude: /node_modules/ }
]
},
plugins: [HtmlWebpackPluginConfig]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment