Skip to content

Instantly share code, notes, and snippets.

@estrattonbailey
Last active September 10, 2017 18:31
Show Gist options
  • Save estrattonbailey/08bf51fc07d431a839f3c05a4653138f to your computer and use it in GitHub Desktop.
Save estrattonbailey/08bf51fc07d431a839f3c05a4653138f to your computer and use it in GitHub Desktop.
webpack config
// imports...
if (module.hot) {
module.hot.accept()
}
import style from '../styles/main.css'
// app code...
<html>
<head></head>
<body>
<script>
__webpack_public_path__ = 'https://localhost:3000/'
</script>
<script src='client.js'></script>
</body>
</html>
const compiler = require('webpack')(config) // webpack.config.js
// ...
app.use(webpackDevMiddleware(compiler, {
noInfo: true,
publicPath: '/',
stats: 'errors-only'
}))
app.use(webpackHotMiddleware(compiler))
// ...
const path = require('path')
const webpack = require('webpack')
module.exports = {
target: 'web',
devtool: 'source-map',
entry: [
'webpack-hot-middleware/client?dynamicPublicPath=true',
path.join(__dirname, 'src/scripts/app.js')
],
output: {
path: __dirname,
filename: 'index.js',
publicPath: '//localhost:3000',
},
module: {
rules: [
{
enforce: 'pre',
test: /\.js?$/,
loader: 'standard-loader',
include: '/src/scripts/app.js',
exclude: /node_modules/,
options: {
parser: 'babel-eslint'
}
},
{
test: /\.js$/,
exclude: /node_modules/,
include: path.join(__dirname, 'src/scripts'),
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
exclude: /node_modules|assets/,
include: path.join(__dirname, 'src/styles/main.css'),
use: [
'style-loader',
'css-loader',
'postcss-loader'
]
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment