Skip to content

Instantly share code, notes, and snippets.

@heygema
Created September 1, 2017 17:23
Show Gist options
  • Save heygema/161dceaf054676c710534a3ccbf0d0ac to your computer and use it in GitHub Desktop.
Save heygema/161dceaf054676c710534a3ccbf0d0ac to your computer and use it in GitHub Desktop.
Webpack config for static html site
var debug = process.env.NODE_ENV !== "production";
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: __dirname + '/app/index.html',
filename: 'index.html',
inject: 'body'
})
module.exports = {
devServer: {
historyApiFallback: true
},
entry: [
'./app/app.js'
],
output: {
path: __dirname + '/dist',
filename: 'app.min.js',
},
module: {
loaders: [
{
test: /\.js$/, exclude: /node_modules/,
loader: "babel-loader"
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file-loader',
'image-webpack-loader',
]
}
]
},
plugins: [
HtmlWebpackPluginConfig,
new ExtractTextPlugin("app.min.css")
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment