728x90
// can't use ecma script module. use only common.js
console.log("module >>> ", module);
const path = require('path');
// minimum option
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, './dist'),
/**
* publicPath
* under version 4: publicPath is empty('').
* over version 4: publicPath is auto
*
* can use list
* 1. 'dist/'
* 2. 'https://image.oliveyoung.co.kr/uploads/contents/202410/25oyDay/pc_visual.jpg'
*/
publicPath: 'dist/'
},
mode: 'none',
module: {
/**
* webpack: I don't know what that menas 'import Kiwi...'
* me: thank you for asking, If you don't know somethig, you should check out the rules.
* webpack: perfect
*/
rules: [
{
test: /\.(png|jpg)$/,
/**
* asset/inline :bake image into base64. could be larger file size(more better)
* asset/resource: request image each of them. cost of call is larger
*/
type: 'asset',
parser: {
dataUrlCondition: {
maxSize: 3 * 1024 // 3kilobyte
}
}
},
{
test: /\.txt$/,
type: 'asset/source'
},
{
// loader should be installed explicitly
test: /\.css$/,
use: [
'style-loader', 'css-loader'
]
},
{
test: /\.scss$/,
// webpack invoke right to left in array
//
use: [
'style-loader', 'css-loader', 'sass-loader'
]
}
]
}
}
npm install style-loader css-lodaer sass sass-loader --save-dev
$font-size: 20px;
$button-background-color: green;
$button-font-color: white;
$text-font-color: red;
.hello-world-button {
font-size: $font-size;
padding: 7px 15px;
background: $button-background-color;
color: $button-font-color;
outline: none;
}
.hello-world-text {
color: $text-font-color;
font-weight: bold;
}
'서버 > Webpack' 카테고리의 다른 글
Webpack - bundling 사이즈 줄이기 간단하게 실습 (1) | 2024.11.05 |
---|---|
Webpack - ecmascript 최신 내용 적용 안될 때 babel을 추가하여 빌드하기 (0) | 2024.11.05 |
Webpack - vue, react처럼 component 직접 만들어보기 (3) | 2024.10.28 |
Webpack - txt를 빌드할 때 넣어보기 (1) | 2024.10.28 |
react (cra) - webpack 커스텀 react-app-rewired (pc, wv 분리) (1) | 2024.10.27 |