Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript webpack将所有内容构建到子文件夹中,index.html除外_Javascript_Webpack_Html Webpack Plugin - Fatal编程技术网

Javascript webpack将所有内容构建到子文件夹中,index.html除外

Javascript webpack将所有内容构建到子文件夹中,index.html除外,javascript,webpack,html-webpack-plugin,Javascript,Webpack,Html Webpack Plugin,我有这个结构 index.html src/img/image.png src/js/app.js src/fonts/font.ttf src/css/styles.css 对于我的发行版,我希望将所有内容构建到一个文件夹中,但html文件除外,如下所示: dist/index.html dist/assets/styles.css dist/assets/app.js dist/assets/font.ttf ..... 这就是我现在正在尝试的,但似乎webpack仍然构建资产文件夹中的

我有这个结构

index.html
src/img/image.png
src/js/app.js
src/fonts/font.ttf
src/css/styles.css
对于我的发行版,我希望将所有内容构建到一个文件夹中,但html文件除外,如下所示:

dist/index.html
dist/assets/styles.css
dist/assets/app.js
dist/assets/font.ttf
.....
这就是我现在正在尝试的,但似乎webpack仍然构建资产文件夹中的所有内容,包括index.html

output: {
path: path.join(__dirname, 'dist/Assets'),
filename: '[name].[hash].bundle.js'
},

plugins:[   
 new HtmlWebpackPlugin({
  template: 'src/index.html',
  chunksSortMode: 'dependency',
  filename: path.resolve(__dirname, './index.html'),
}),
]

您可以将第二个参数更改为
“../index.html”

 new HtmlWebpackPlugin({
  template: 'src/index.html',
  chunksSortMode: 'dependency',
  filename: path.resolve(__dirname, '../index.html'),
}),