I am trying to add the copy-webpack-plugin to my asp .net core 2-angular5 web application. I have installed copy-webpack-plugin. I am recieving the following error on running webpack.js :
new webpack.CopyWebpackPlugin(
^
TypeError: webpack.CopyWebpackPlugin is not a constructor
Here is the webpack.config.js
const CopyWebpackPlugin = require('copy-webpack-plugin').CopyWebpackPlugin;
....
const clientBundleConfig = merge(sharedConfig, {
entry: { 'main-client': './ClientApp/boot.browser.ts' },
output: { path: path.join(__dirname, clientBundleOutputDir) },
plugins: [
new webpack.CopyWebpackPlugin(
{ from: './ClientApp/assets', to: './wwwroot/dist/assets', toType : 'dir' }
),
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json')
})
].concat(isDevBuild ? [
// Plugins that apply in development builds only
new webpack.SourceMapDevToolPlugin({
filename: '[file].map', // Remove this line if you prefer inline source maps
moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
})
] : [
// Plugins that apply in production builds only
new webpack.optimize.UglifyJsPlugin(),
new AngularCompilerPlugin({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'ClientApp/app/app.browser.module#AppModule'),
exclude: ['./**/*.server.ts']
})
])
});
How do I solve this error?