Skip to content

Commit 00e8998

Browse files
author
Nir Maoz
authored
Fix videojs-font broken import (#123)
* Add prebuild and pretest scripts
1 parent f551399 commit 00e8998

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
"build-light": "WEBPACK_BUILD_LIGHT=1 webpack --config webpack/es5.config.js --progress --display-error-details --color",
1212
"analyze": "webpack --config webpack/minified.config.js --json | webpack-bundle-size-analyzer",
1313
"build-all": "npm run clean && npm run build-dev && npm run build && npm run build-light",
14-
"prebuild": "sed -i.bak 's:../../node_modules:../../..:' node_modules/video.js/src/css/video-js.scss",
14+
"prebuild": "node webpack/pre-build.js",
1515
"precommit": "eslint src",
1616
"predeploy": "deploy=true npm run build-all",
1717
"deploy": "deploy=true node webpack/deploy.js",
1818
"postdeploy": "git push origin master --follow-tags",
1919
"dry:deploy": "node webpack/deploy.js dry",
20-
"test": "jest --no-cache --detectOpenHandles"
20+
"test": "jest --no-cache --detectOpenHandles",
21+
"pretest": "node webpack/pre-build.js"
2122
},
2223
"author": "Cloudinary",
2324
"license": "MIT",

webpack/pre-build.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Fix a line in video-js.scss that contains a wrong import path.
3+
* video-js.scss assumes that 'videojs-font' is located in a different location from what we have.
4+
*/
5+
6+
const fs = require('fs');
7+
8+
/**
9+
* Replace an expression in a file
10+
* @param file
11+
* @param searchValue
12+
* @param newValue
13+
*/
14+
const replace = (file, searchValue, newValue) => {
15+
fs.readFile(file, 'utf8', function (err, data) {
16+
if (err) {
17+
console.error(err);
18+
throw (err);
19+
}
20+
21+
const result = data.replace(searchValue, newValue);
22+
23+
fs.writeFile(file, result, 'utf8', function (err) {
24+
if (err) {
25+
console.error(err);
26+
throw (err);
27+
}
28+
});
29+
});
30+
};
31+
32+
33+
// Replace the wrong import path with the correct one
34+
replace('node_modules/video.js/src/css/video-js.scss', '../../node_modules', '../../..');

0 commit comments

Comments
 (0)