Created
April 19, 2020 06:41
-
-
Save sp0033212000/71d81b722c69b489e35997e0e696d312 to your computer and use it in GitHub Desktop.
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
const webpack = require("webpack"); | |
const path = require("path"); | |
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
const HtmlWebpackPlugin = require("html-webpack-plugin"); | |
const InterpolateHtmlPlugin = require("react-dev-utils/InterpolateHtmlPlugin"); | |
module.exports = { | |
mode: "development", | |
target: "web", | |
entry: { | |
main: [ | |
"webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000", | |
"./src/index.js", | |
], | |
}, | |
output: { | |
path: path.join(__dirname, "bundle"), | |
filename: "js/bundle.js", | |
publicPath: "/", | |
}, | |
devServer: { | |
contentBase: "./public", | |
historyApiFallback: true, | |
https: true, | |
port: 3000, | |
}, | |
devtool: "inline-source-map", | |
module: { | |
rules: [ | |
{ | |
use: "babel-loader", | |
test: /\.js$/, | |
exclude: /node_modules/, | |
}, | |
{ | |
// Loads the javacript into html template provided. | |
// Entry point is set below in HtmlWebPackPlugin in Plugins | |
test: /\.html$/, | |
use: [ | |
{ | |
loader: "html-loader", | |
//options: { minimize: true } | |
}, | |
], | |
}, | |
{ | |
use: "babel-loader", | |
test: /\.js$/, | |
exclude: /node_modules/, | |
}, | |
{ | |
use: [MiniCssExtractPlugin.loader, "css-loader"], | |
test: /\.css$/, | |
}, | |
{ | |
test: /\.(jpe?g|png|gif|svg|ico|json)$/, | |
use: [ | |
{ | |
loader: "url-loader", | |
options: { | |
limit: 40000, | |
name: "assets/[path][name].[ext]", | |
context: path.resolve(__dirname, "src/assets"), | |
}, | |
}, | |
"image-webpack-loader", | |
], | |
}, | |
], | |
}, | |
plugins: [ | |
new HtmlWebpackPlugin({ | |
inject: true, | |
template: path.resolve("public/index.html"), | |
filename: "index.html", | |
excludeChunks: ["server"], | |
}), | |
new InterpolateHtmlPlugin(HtmlWebpackPlugin, { | |
PUBLIC_URL: "public", | |
}), | |
new MiniCssExtractPlugin({ | |
filename: "css/[name].css", | |
chunkFilename: "css/[id].css", | |
}), | |
new webpack.DefinePlugin({ | |
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV), | |
}), | |
new webpack.optimize.OccurrenceOrderPlugin(), | |
new webpack.HotModuleReplacementPlugin(), | |
new webpack.NoEmitOnErrorsPlugin(), | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment