Skip to content

Instantly share code, notes, and snippets.

@helpse
Created April 1, 2017 03:32
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save helpse/a3419706c1d937470fedf31800b7f625 to your computer and use it in GitHub Desktop.
Save helpse/a3419706c1d937470fedf31800b7f625 to your computer and use it in GitHub Desktop.
Webpack + dev server + hot reloading + pug + sass
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;
@Koniksan
Copy link

Will be better with package.json to =)

@itwasmattgregg
Copy link

+1 for a package.json and maybe a rough directory structure to go with

@ecklf
Copy link

ecklf commented Jun 5, 2018

Made a repo for webpack4 /w package.json here

@faherrera
Copy link

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment