Last active
September 10, 2017 18:31
-
-
Save estrattonbailey/08bf51fc07d431a839f3c05a4653138f to your computer and use it in GitHub Desktop.
webpack config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// imports... | |
if (module.hot) { | |
module.hot.accept() | |
} | |
import style from '../styles/main.css' | |
// app code... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head></head> | |
<body> | |
<script> | |
__webpack_public_path__ = 'https://localhost:3000/' | |
</script> | |
<script src='client.js'></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const compiler = require('webpack')(config) // webpack.config.js | |
// ... | |
app.use(webpackDevMiddleware(compiler, { | |
noInfo: true, | |
publicPath: '/', | |
stats: 'errors-only' | |
})) | |
app.use(webpackHotMiddleware(compiler)) | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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