erikdesjardins / zip-webpack-plugin

Webpack plugin to zip up emitted files.
https://www.npmjs.com/package/zip-webpack-plugin
MIT License
106 stars 22 forks source link

HTML files not being included #13

Closed Eldelshell closed 6 years ago

Eldelshell commented 7 years ago

Hi, first, thanks for this plugin, works great.

I'm having an issue where all the HTML files I'm generating are not being included. I can see that the files are generated (using Handlebars) before everything else on my dist folder:

├── 270f7f934eae976855e77fbbfc25ad3c.otf
├── 6b4146d5e03135453263e68e9c967ee5.png
├── bundle-20170427T1558304275.js
├── ee24fea0d5a58001155b65c93f47d44c.otf
├── index.html
├── lib
│   ├── jquery.min.js
│   └── bootstrap.js
├── main-20170427T1558304275.css
├── page1.html
├── page2.html
└── page3.html

All other files are included (even the ones on the lib folder).

I've tried with the default (empty) configuration and with:

const zipPlugin = new ZipPlugin({
    path: '../releases',
    include: [/\.(jpe?g|gif|png|svg|woff(2)?|ttf|otf|js|css|html)$/],
    exclude: null,
    filename: `${NPM_INFO.name}-${NPM_INFO.version}-${build}.zip`
});

Thanks for any help.

erikdesjardins commented 7 years ago

Sorry about the delay; if you're still facing this issue, which Handlebars plugin/loader (there are multiple) are you using to generate those files?

I'm guessing it's one of two things:

erikdesjardins commented 6 years ago

Closing due to staleness, will reopen if I get more info

kazuma1989 commented 6 years ago

I was running into the same issue but just found a workaround. Place html-webpack-plugin instances before zip-webpack-plugin instance.

e.g.) in webpack.config.js:

Bad (generated HTMLs will not be included)

  plugins: [
    new ZipWebpackPlugin(),
    new HtmlWebpackPlugin(),
  ]

Good (generated HTMLs will be included)

  plugins: [
    new HtmlWebpackPlugin(),
    new ZipWebpackPlugin(),
  ]

If you use webpack-merge, try using merge.strategy().

Package versions:

"html-webpack-plugin": "^2.30.1",
"webpack": "1.15.0",
"zip-webpack-plugin": "0.3.0"

Because I'm using webpack@v1 for some reason, packages I'm using are so old that the current versions may not have the issue.

mahesh4kc commented 4 years ago

Angular 9 generates two main files like below but inside the zip it packages only one file(main-es2015.3340488709685d4e325a.js) main-es5.3340488709685d4e325a.js main-es2015.3340488709685d4e325a.js

new HtmlWebpackPlugin(), new ZipPlugin({ path: path.resolve(__dirname,'dist'), filename: 'a.zip', include: [/.(jpe?g|gif|png|svg|woff(2)?|txt|ico|js|css|html)$/], exclude: null,
}) ]