기본 설정
1. install npm (json 파일 생성)
2. npm i -D webpack webpack-cli webpack-de
3. package.json 내용 수정
"scripts": {
"dev": "webpack-dev-server --mode development",
"build": "webpack --mode production"
}
4. webpack.cofig.js 파일 생성 (기본구성이라 아래와는 별개입니다)
const path = require('path')
module.exports = {
// 파일을 읽어들이기 시작하는 진입점 설정
entry: './js/main.js',
// 결과물(번들)을 변환하는 설정 (결과물을 dist 라는 폴더 내에 만들어줌)
output: {
path: path.resolve(__dirname, 'dist'), //node.js 요구하는 절대경로를 명시해줘야함)
filename:'main.js'
clean: true // 필요하지 않은 것들을 제거할 수 있음
}
}
const path = require('path')
const HtmlPlugin = require('html-webpack-plugin')
module.exports = {
entry: './js/main.js',
output: {clean: true}
},
//번들링 후 결과물의 처리 방식 등 다 양한 플러그인들을 설정
plugins: [
new HtmlPlugin({
templete: './index.html'})]
devServer: {
host: 'localhost'
}
import '../css/main.css'
npm i -D css-loader style-loader (terminal) 패키지를 따로 깔아도 된다. config 파일 수정
module: {
rules: [
{
test: /|.css$/, // .css 로 끝나는 것을 찾는 정규식
use: [
'style-loader',
'css-loader'
]
}]
}
.gitignore 파일 생성
.cache
.DS_Store
node_modules
dist
후에 git init
배포사이트 접속
배포사이트
로그인 후 new site from git 버튼 클릭
create a new site
github 클릭 (로그인)
원하는 저장소 선택 후
basic build settings 목록을 잘 봐야함
deploy site 버튼 클릭
그러면 주소를 생성해줌! 그걸 배포하면 댐