Skip to content

Instantly share code, notes, and snippets.

@gyeongseokKang
Created July 6, 2021 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gyeongseokKang/7ebee13697b32854bd96d1fb973144d1 to your computer and use it in GitHub Desktop.
Save gyeongseokKang/7ebee13697b32854bd96d1fb973144d1 to your computer and use it in GitHub Desktop.
webpack 설정 완성본
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: "./src/index.tsx",
mode: "development",
devtool: "inline-source-map", // <- source map를 위한 코드
devServer: {
contentBase: "./dist", //
historyApiFallback: true, // <- dev-server를 위한 코드
}, //
target: "web", //
module: {
rules: [
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource",
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: "asset/resource",
},
{
test: /\.(csv|tsv)$/i,
use: ["csv-loader"],
},
{
test: /\.(ts|tsx)$/i,
use: "babel-loader",
exclude: /node_modules/,
},
{
test: /\.(csv|tsv)$/i,
use: ["csv-loader"],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".jsx"],
alias: {
root: __dirname,
src: path.resolve(__dirname, "src"),
},
},
output: {
filename: "[name].bundle.js",
path: path.resolve(__dirname, "dist"),
clean: true,
},
plugins: [
new HtmlWebpackPlugin({
title: "my project",
template: path.join(__dirname, "./public/index.html"),
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment