리소스 : test,include,exclude, resource tag로 설정 가능하고, 정규화 식을 사용한다. 단, test와 resource tag는 혼용 할 수 없다
발행자(issuer) : 발행자의 경우는 entry인 index.js에 import 처리 하면 output 파일에 bundle 된다
use의 경우 로드된 리소스를 처리하는 모듈을 지정할 수 있다. 지정된 모듈은 chained되게 연속적으로 실행 되지만, 주의할 점은 실행의 순서가 맨 마지막에서 처음으로 로드된다는 것이다. 여기서는 'css-loader' 이후에 'style-loader'가 실행 된다.
issuer 처리를 위해서 다음 코드를 추가한다
src/index.js
import _ from 'lodash' + import './style.css'
function component() { let element = document.createElement('div');
// Lodash, currently included via a script, is required for this line to work element.innerHTML = _.join(['Hello', 'webpack'], ' '); + element.classList.add('hello'); return element; }
document.body.appendChild(component());
issuer인 import './style.css'를 entry에 표현 하지 않으면 해당 css 파일은 build시 bundle 제외 된다.
import _ from 'lodash' import './style.css' + import Icon from './icon.png';
function component() { let element = document.createElement('div');
// Lodash, currently included via a script, is required for this line to work element.innerHTML = _.join(['Hello', 'webpack'], ' '); element.classList.add('hello');
+ var myIcon = new Image(); + myIcon.src = Icon; + element.appendChild(myIcon);
return element; }
document.body.appendChild(component());
이 정도로 해당 icon.png는 bundle되게 된다. 그러나 만약에 해당 png를 entry에서 로드 하지 않고 css에서만 사용한다고 해도 entry가 style을 부르고 style에서 icon.png를 부르기 때문에 bundle처리 된다.