title: How can I copy a folder to public path with webpack?
body: <p>I have a folder (ClientApp/static/assets/i18n) in my Angular2/ASP.NET Core App which contains different json files where translations are stored. I want to copy them to the public dist folder so that the files are available for the browser under <a href="http://localhost:54135/assets/i18n/en.json" rel="nofollow noreferrer">http://localhost:54135/assets/i18n/en.json</a> for instance. </p>
  
  <p>How can I achieve that using webpack with the staticBundleConfig. I've tried, but I don't quite get the meaning of the entry point in this case. It doesn't work either. Any help in achieving that?</p>
  
  <pre><code>    var isDevBuild = process.argv.indexOf('--env.prod') &lt; 0;
  var path = require('path');
  var webpack = require('webpack');
  var CopyWebpackPlugin = require('copy-webpack-plugin');
  var nodeExternals = require('webpack-node-externals');
  var merge = require('webpack-merge');
  var allFilenamesExceptJavaScript = /\.(?!js(\?|$))([^.]+(\?|$))/;
  
  // Configuration in common to both client-side and server-side bundles
  var sharedConfig = {
      resolve: { extensions: [ '', '.js', '.ts' ] },
      output: {
          filename: '[name].js',
          publicPath: '/dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix
      },
      module: {
          loaders: [
              { test: /\.ts$/, include: /ClientApp/, loader: 'ts', query: { silent: true } },
              { test: /\.html$/, loader: 'raw' },
              { test: /\.json$/, include: /ClientApp/, loader: 'json'},
              { test: /\.css$/, loader: 'to-string!css' },
              { test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url', query: { limit: 25000 } }
          ]
      }
  };
  
  // Configuration for client-side bundle suitable for running in browsers
  var clientBundleConfig = merge(sharedConfig, {
      entry: { 'main-client': './ClientApp/boot-client.ts' },
      output: { path: path.join(__dirname, './wwwroot/dist') },
      devtool: isDevBuild ? 'inline-source-map' : null,
      plugins: [
          new webpack.DllReferencePlugin({
              context: __dirname,
              manifest: require('./wwwroot/dist/vendor-manifest.json')
          })
      ].concat(isDevBuild ? [] : [
          // Plugins that apply in production builds only
          new webpack.optimize.OccurenceOrderPlugin(),
          new webpack.optimize.UglifyJsPlugin()
      ])
  });
  
  var staticBundleConfig = merge(sharedConfig, {
  
      //entry: { 'static': './ClientApp/boot.ts' },
      output: { path: path.join(__dirname, './wwwroot/dist') },
      plugins: [
          new CopyWebpackPlugin([
              { from: './ClientApp/static', to: path.join(__dirname, './wwwroot/dist') }
          ])
      ]
  });
  
  // Configuration for server-side (prerendering) bundle suitable for running in Node
  var serverBundleConfig = merge(sharedConfig, {
      entry: { 'main-server': './ClientApp/boot-server.ts' },
      output: {
          libraryTarget: 'commonjs',
          path: path.join(__dirname, './ClientApp/dist')
      },
      target: 'node',
      devtool: 'inline-source-map',
      externals: [nodeExternals({ whitelist: [allFilenamesExceptJavaScript] })] // Don't bundle .js files from node_modules
  });
  
  module.exports = [clientBundleConfig, serverBundleConfig, staticBundleConfig];
  </code></pre>