Skip to content

Commit 9e60925

Browse files
deps: Remove serialize-javascript dependency (#6884)
1 parent 48de147 commit 9e60925

4 files changed

Lines changed: 52 additions & 81 deletions

File tree

frontend/package-lock.json

Lines changed: 19 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
"clean-webpack-plugin": "0.1.19",
7171
"color": "3.1.0",
7272
"colors": "1.4.0",
73-
"copy-webpack-plugin": "^9.1.0",
7473
"cors": "^2.8.3",
7574
"cross-env": "7.0.3",
7675
"css-loader": "6.8.1",

frontend/webpack/plugins.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
const path = require('path');
2-
const CopyWebpackPlugin = require('copy-webpack-plugin');
2+
const fs = require('fs');
33
const 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: /^\.\/locale$/,
1433
contextRegExp: /moment$/,
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;

frontend/webpack/webpack.config.django.prod.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ const path = require('path');
55
const webpack = require('webpack');
66
const HtmlWebpackPlugin = require('html-webpack-plugin');
77
const CleanWebpackPlugin = require('clean-webpack-plugin');
8-
const CopyWebpackPlugin = require('copy-webpack-plugin');
98
const TerserPlugin = require('terser-webpack-plugin');
109
const moment = require('moment');
1110
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
1211
const base = require('../webpack.config');
12+
const { CopyStaticPlugin } = require('./plugins');
1313

1414
module.exports = {
1515
...base,
@@ -49,12 +49,9 @@ module.exports = {
4949
}),
5050

5151
// Copy static content
52-
new CopyWebpackPlugin(
53-
{
54-
patterns: [
55-
{ from: path.join(__dirname, '../web/static'), to: path.join(__dirname, '../../api/static') },
56-
],
57-
},
52+
new CopyStaticPlugin(
53+
path.join(__dirname, '../web/static'),
54+
path.join(__dirname, '../../api/static'),
5855
),
5956

6057
]).concat(require('./pages').map(page => new HtmlWebpackPlugin({

0 commit comments

Comments
 (0)