11const path = require ( 'path' ) ;
2- const CopyWebpackPlugin = require ( 'copy-webpack-plugin ' ) ;
2+ const fs = require ( 'fs ' ) ;
33const webpack = require ( 'webpack' ) ;
44
5- module . exports = [
5+ class CopyStaticPlugin {
6+ constructor ( src , dest ) {
7+ this . src = src ;
8+ this . dest = dest ;
9+ }
10+
11+ apply ( compiler ) {
12+ compiler . hooks . afterEmit . tap ( 'CopyStaticPlugin' , ( ) => {
13+ try {
14+ fs . cpSync ( this . src , this . dest , { recursive : true } ) ;
15+ } catch ( error ) {
16+ compiler . errors . push (
17+ new Error ( `CopyStaticPlugin: Failed to copy ${ this . src } to ${ this . dest } : ${ error . message } ` )
18+ ) ;
19+ }
20+ } ) ;
21+ }
22+ }
23+
24+ const plugins = [
625
726 new webpack . DefinePlugin ( {
827 SENTRY_RELEASE_VERSION : true ,
@@ -13,11 +32,13 @@ module.exports = [
1332 resourceRegExp : / ^ \. \/ l o c a l e $ / ,
1433 contextRegExp : / m o m e n t $ / ,
1534 } ) ,
16- //
1735 // Copy static content
18- new CopyWebpackPlugin ( {
19- patterns : [
20- { from : path . join ( __dirname , '../web/static' ) , to : path . join ( __dirname , '../public/static' ) } ,
21- ] ,
22- } ) ,
36+ new CopyStaticPlugin (
37+ path . join ( __dirname , '../web/static' ) ,
38+ path . join ( __dirname , '../public/static' ) ,
39+ ) ,
2340] ;
41+
42+ plugins . CopyStaticPlugin = CopyStaticPlugin ;
43+
44+ module . exports = plugins ;
0 commit comments