Skip to content

🎥 Make videos programmatically with React

remove copy-webpack-plugin

Jonny Burgerf429bb5a2f5e
diff --git a/packages/skia/package.json b/packages/skia/package.json
index d9ef8472ec..208c55f726 100644
--- a/packages/skia/package.json
+++ b/packages/skia/package.json
@@ -21,7 +21,6 @@
"url": "https://github.com/remotion-dev/remotion/issues"
},
"dependencies": {
- "copy-webpack-plugin": "11",
"remotion": "workspace:*"
},
"peerDependencies": {
diff --git a/packages/skia/rollup-enable.config.js b/packages/skia/rollup-enable.config.js
index a2381b75c3..12633dfa6f 100644
--- a/packages/skia/rollup-enable.config.js
+++ b/packages/skia/rollup-enable.config.js
@@ -11,7 +11,7 @@ export default [
sourcemap: false,
},
],
- external: ['react', 'copy-webpack-plugin'],
+ external: ['react'],
plugins: [
typescript({
tsconfig: 'tsconfig-esm.json',
diff --git a/packages/skia/src/enable.ts b/packages/skia/src/enable.ts
index d573f3e8e5..c22cc32daf 100644
--- a/packages/skia/src/enable.ts
+++ b/packages/skia/src/enable.ts
@@ -1,5 +1,6 @@
import type {WebpackOverrideFn} from '@remotion/bundler';
-import CopyPlugin from 'copy-webpack-plugin';
+import {webpack} from '@remotion/bundler';
+import fs from 'fs';
/**
* @description A function that modifies the default Webpack configuration to make the necessary changes to support Skia.
@@ -10,11 +11,33 @@ export const enableSkia: WebpackOverrideFn = (currentConfiguration) => {
...currentConfiguration,
plugins: [
...(currentConfiguration.plugins ?? []),
- new CopyPlugin({
- patterns: [
- {from: 'node_modules/canvaskit-wasm/bin/full/canvaskit.wasm'},
- ],
- }),
+ new (class CopySkiaPlugin {
+ apply(compiler: webpack.Compiler) {
+ compiler.hooks.thisCompilation.tap('AddSkiaPlugin', (compilation) => {
+ compilation.hooks.processAssets.tapPromise(
+ {
+ name: 'copy-skia',
+ stage:
+ compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
+ },
+ async () => {
+ const src = require.resolve(
+ 'canvaskit-wasm/bin/full/canvaskit.wasm'
+ );
+ if (compilation.getAsset(src)) {
+ // Skip emitting the asset again because it's immutable
+ return;
+ }
+
+ compilation.emitAsset(
+ '/canvaskit.wasm',
+ new webpack.sources.RawSource(await fs.promises.readFile(src))
+ );
+ }
+ );
+ });
+ }
+ })(),
],
resolve: {
...currentConfiguration.resolve,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a93bbece5b..ed58f6dc90 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1119,7 +1119,6 @@ importers:
'@shopify/react-native-skia': ^0.1.190
'@types/react': 18.0.26
'@types/react-native': ^0.69.2
- copy-webpack-plugin: '11'
eslint: 8.25.0
prettier: ^2.7.1
prettier-plugin-organize-imports: ^2.3.4
@@ -1129,7 +1128,6 @@ importers:
rollup: ^2.70.1
typescript: ^4.7.0
dependencies:
- copy-webpack-plugin: [email protected]
remotion: link:../core
devDependencies:
'@jonny/eslint-config': 3.0.266_t54va6jeo5lf3vtqih5uiyrm5e
@@ -11794,21 +11792,6 @@ packages:
webpack: 5.74.0_@[email protected]
dev: false
- /copy-webpack-plugin/[email protected]:
- resolution: {integrity: sha512-fX2MWpamkW0hZxMEg0+mYnA40LTosOSa5TqZ9GYIBzyJa9C3QUaMPSE2xAi/buNr8u89SfD9wHSQVBzrRa/SOQ==}
- engines: {node: '>= 14.15.0'}
- peerDependencies:
- webpack: ^5.1.0
- dependencies:
- fast-glob: 3.2.11
- glob-parent: 6.0.2
- globby: 13.1.2
- normalize-path: 3.0.0
- schema-utils: 4.0.0
- serialize-javascript: 6.0.0
- webpack: 5.76.1
- dev: false
-
/core-js-compat/3.18.1:
resolution: {integrity: sha512-XJMYx58zo4W0kLPmIingVZA10+7TuKrMLPt83+EzDmxFJQUMcTVVmQ+n5JP4r6Z14qSzhQBRi3NSWoeVyKKXUg==}
dependencies: