Created
September 1, 2017 17:23
-
-
Save heygema/161dceaf054676c710534a3ccbf0d0ac to your computer and use it in GitHub Desktop.
Webpack config for static html site
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 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