Skip to content

Instantly share code, notes, and snippets.

@calimaborges
Created July 21, 2017 20:22
Show Gist options
  • Save calimaborges/b64c61cd9d662a6ceb0a5dc3fe9142aa to your computer and use it in GitHub Desktop.
Save calimaborges/b64c61cd9d662a6ceb0a5dc3fe9142aa to your computer and use it in GitHub Desktop.
Webpack Basic Config Example
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const webpack = require("webpack");
module.exports = {
devtool: "source-map",
entry: "./src/index.js",
output: {
filename: "[name].[hash].js",
path: path.resolve(__dirname, "dist")
},
plugins: [
new CleanWebpackPlugin(["dist"]),
new HtmlWebpackPlugin({
template: "public/index.html"
}),
new webpack.HotModuleReplacementPlugin()
],
devServer: {
port: 8000,
host: "local.tst.jus.br",
historyApiFallback: true,
noInfo: false,
stats: "minimal",
hot: true,
contentBase: path.resolve(__dirname, "dist"),
publicPath: "/"
},
module: {
rules: [
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
loader: "url-loader?limit=100000"
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "babel-loader",
options: {
presets: ["env", "react"],
plugins: [
"transform-object-rest-spread",
"transform-class-properties"
]
}
}
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment