구성 없는 단순한 자동 번들링으로 소/중형 프로젝트에 적합하다.
npm install -D parcel-bundler
"scripts": {
"dev": "parcel index.html",
"build": "parcel build index.html"
}
index.html
js/main.js
scss/main.scss
파일 생성 후 html에 연결한 후npm run build
를 하면 html, js, scss 파일을 사용할 수 있다.
npm i -D parcel-plugin-static-files-copy
"staticFiles" : {
"staticPath" : "static"
// static 폴더를 dist 폴더에 자동으로 추가함
}
dist 폴더 생성 후 그 폴더에 logo.png 이미지 추가 후 index.html 파일에 연결한 후
npm run dev
하면 static 폴더 안의 정적 파일과 scss, js 자동으로 연결된다.
npm i -D postcss autoprefixer
"browserslist" : [
"> 1%", // 점유율이 1% 이상인
"last 2 versions" // 마지막 2개 버전까지는 지원함
]
// postcssrc.js
// nodejs에선 CommonJS이기 때문에 import 대신 require()을 export 대신 module.exports을 사용해야 한다.
module.exports = {
plugins: [
require('autoprefixer') // 간소화
]
}
PostCSS plugin autoprefixer requires PostCSS 에러 시
npm i -D autoprefixer@9
npm i @babel/core @babel/preset-env
// .babelrc.js
module.exports = {
presets:['@babel/preset-env']
}