Created
April 1, 2017 03:32
-
-
Save helpse/a3419706c1d937470fedf31800b7f625 to your computer and use it in GitHub Desktop.
Webpack + dev server + hot reloading + pug + sass
This file contains 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
var webpack = require('webpack'); | |
var path = require('path'); | |
var HtmlWebpackPlugin = require('html-webpack-plugin'); | |
var src = path.join(__dirname, 'src'); | |
var config = { | |
devServer: { | |
hot: true, | |
inline: true, | |
}, | |
stats: { | |
assets: false, | |
colors: true, | |
version: false, | |
hash: true, | |
timings: true, | |
chunks: false, | |
chunkModules: false | |
}, | |
entry: { | |
styles: path.join(src, 'styles.js'), | |
index: path.join(src, 'index.pug'), | |
bundle: path.join(src, 'index.js'), | |
}, | |
output: { | |
path: path.resolve(__dirname, 'build'), | |
filename: '[name].js' | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.pug$/, | |
use: ['html-loader', 'pug-html-loader?pretty&exports=false'] | |
}, | |
{ | |
test: /\.sass$/, | |
use: ['style-loader', 'css-loader', 'sass-loader'], | |
}, | |
{ | |
test: /\.css$/, | |
use: ['style-loader', 'css-loader'], | |
} | |
] | |
}, | |
plugins: [ | |
new webpack.HotModuleReplacementPlugin(), | |
new HtmlWebpackPlugin({ | |
title: 'index.html', | |
template: path.join(src, 'index.pug'), | |
}), | |
], | |
}; | |
module.exports = config; |
+1 for a package.json and maybe a rough directory structure to go with
Made a repo for webpack4 /w package.json here
thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will be better with package.json to =)