webpack copyplugin copy folders code example

Example: copy webpack plugin not working

var CopyWebpackPlugin = require('copy-webpack-plugin');
var path = require('path');
module.exports = {
  context: path.join(__dirname, 'web/static'),
  devServer: {
    outputPath: path.join(__dirname, 'priv/static')
  },
  entry: {
    landing: []
  },
  output: {
    path: "priv/static",
    filename: "js/[name].js"
  },
  plugins: [
    new CopyWebpackPlugin([
      { from: 'images/', to: 'images/' },
      { from: 'fonts/', to: 'fonts/' },
      { from: 'styles/*.css', to: 'css/', flatten: true },
      { from: 'favicon.ico' },
      { from: 'robots.txt' }
    ])
  ]
};

Tags:

Misc Example