2016-11-14 17 views
1

我目前使用WebpackHtmlPlugin來簡化我的index.html入口點,但是我的主要問題是index.html與所有其他資產(即publicPath points至)。使用HtmlPlugin從子目錄中構建webpack的資產

我想要在一個文件夾中提供index.html,並在子文件夾中通過webpack生成所有資產。事情是這樣的

index.html 
build/ 
    bundle.js 
    1.bundle.js 
    2.bundle.js 

有什麼辦法可以做到這一點,而不去反對的WebPack和手動手中的每個資產映射,並設置publicPath是根?

回答

1

您可以完全HTMLWebpackPlugin使用CopyWebpackPlugin ...

plugins: [ 
    new HtmlWebpackPlugin({ 
     filename: "index.html", 
     template: "index.html", 
     inject: false 
    }), 
    new CopyWebpackPlugin([ 
     { from: 'from/directory/**/*', to: '/absolute/path' }, 
    ]) 
], 

看到https://www.npmjs.com/package/copy-webpack-plugin

參考
相關問題