0
각도 2 앱과 함께 Webpack을 사용하고 있습니다. 내 Webpack 구성 파일의 로더는 다음과 같습니다. 긴 샘플 코드를 피하기 위해 플러그인과 가져 오기를 제거했습니다. Webpack은 css 파일의 이미지를 해시 이름으로 바꾸지 만 html 파일로 바꾸지는 않습니다. 내가 무엇을 놓치고 있는지 잘 모르겠다. 어떤 조언을 부탁드립니다.Webpack은 HTML 파일의 이미지를 대체하지 않습니다.
module.exports = function (options) {
const DATAS = {
VERSION: JSON.stringify(require("../package.json").version),
DEBUG_INFO_ENABLED: options.env === 'dev'
};
return {
entry: {
'polyfills': './src/main/webapp/app/polyfills',
'global': './src/main/webapp/content/css/global.css',
'main': './src/main/webapp/app/app.main'
},
resolve: {
extensions: ['.ts', '.js'],
modules: ['node_modules']
},
module: {
rules: [
{ test: /bootstrap\/dist\/js\/umd\//, loader: 'imports-loader?jQuery=jquery' },
{
test: /\.ts$/,
loaders: [
'angular2-template-loader',
'awesome-typescript-loader'
],
exclude: ['node_modules/generator-jhipster']
},
{
test: /\.html$/,
loader: 'raw-loader',
exclude: ['./src/main/webapp/index.html']
},
{
test: /\.css$/,
loaders: ['to-string-loader', 'css-loader'],
exclude: /(vendor\.css|global\.css)/
},
{
test: /(vendor\.css|global\.css)/,
loaders: ['style-loader', 'css-loader']
},
{
test: /\.(jpe?g|png|gif|svg|woff|woff2|ttf|eot)$/i,
loaders: [
'file-loader?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack-loader?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
},
{
test: /app.constants.ts$/,
loader: StringReplacePlugin.replace({
replacements: [{
pattern: /\/\* @toreplace (\w*?) \*\//ig,
replacement: function (match, p1, offset, string) {
return `_${p1} = ${DATAS[p1]};`;
}
}]
})
}
]
}
다른 SO 답변을 기반으로 정확히 동일합니다. ./src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts 모듈을 찾을 수 없습니다 : 오류 : 오류가 발생했습니다. '/ Users/company/folder/myapp'의 'html-loader'를 해결할 수 없습니다. @ ./src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts 46 : 18-65 @ ./src/main/webapp/app/account/index.ts @ ./src/main/webapp/app/account/account.module.ts @ ./src/main/webapp/ app/app.module.ts @./src/main/webapp/app/app.main.ts' 이상 코드가 있습니다. – TechCrunch
'npm install --save-dev html-loader'와 함께'html-loader'를 설치해야합니다. –
처음으로 webpack을 사용 중이며 Wepack이 모듈을 라이브러리에서로드한다고 가정합니다. 나는 여러 가지 일을 시도하면서 문자 그대로 적어도 2 일을 낭비했다. 고마워. – TechCrunch