Created
July 6, 2021 11:51
-
-
Save gyeongseokKang/7ebee13697b32854bd96d1fb973144d1 to your computer and use it in GitHub Desktop.
webpack 설정 완성본
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 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