mirror of https://github.com/laurent22/joplin.git
Tools: Speed up building mobile CodeMirror when nothing has changed
parent
b2d59002bb
commit
0678dad2d6
|
@ -0,0 +1 @@
|
||||||
|
0e1c132c199587530715a478bdb29a74
|
|
@ -101,6 +101,7 @@
|
||||||
"jest-environment-jsdom": "29.3.1",
|
"jest-environment-jsdom": "29.3.1",
|
||||||
"jetifier": "2.0.0",
|
"jetifier": "2.0.0",
|
||||||
"jsdom": "20.0.0",
|
"jsdom": "20.0.0",
|
||||||
|
"md5-file": "5.0.0",
|
||||||
"metro-react-native-babel-preset": "0.67.0",
|
"metro-react-native-babel-preset": "0.67.0",
|
||||||
"nodemon": "2.0.20",
|
"nodemon": "2.0.20",
|
||||||
"ts-jest": "29.0.3",
|
"ts-jest": "29.0.3",
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
// files: First here we convert the JS file to a plain string, and that string
|
// files: First here we convert the JS file to a plain string, and that string
|
||||||
// is then loaded by eg. the Mermaid plugin, and finally injected in the WebView.
|
// is then loaded by eg. the Mermaid plugin, and finally injected in the WebView.
|
||||||
|
|
||||||
import { mkdirp, readFile, writeFile } from 'fs-extra';
|
import { mkdirp, pathExists, readFile, writeFile } from 'fs-extra';
|
||||||
import { dirname, extname, basename } from 'path';
|
import { dirname, extname, basename } from 'path';
|
||||||
|
const md5File = require('md5-file');
|
||||||
const execa = require('execa');
|
const execa = require('execa');
|
||||||
|
|
||||||
// We need this to be transpiled to `const webpack = require('webpack')`.
|
// We need this to be transpiled to `const webpack = require('webpack')`.
|
||||||
|
@ -77,19 +78,34 @@ class BundledFile {
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.tsx', '.ts', '.js'],
|
extensions: ['.tsx', '.ts', '.js'],
|
||||||
},
|
},
|
||||||
|
cache: {
|
||||||
|
type: 'filesystem',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async uglify() {
|
private async uglify() {
|
||||||
|
const md5Path = `${this.bundleOutputPath}.md5`;
|
||||||
|
const newMd5 = await md5File(this.bundleOutputPath);
|
||||||
|
const previousMd5 = await pathExists(md5Path) ? await readFile(md5Path, 'utf8') : '';
|
||||||
|
|
||||||
|
if (newMd5 === previousMd5 && await pathExists(this.bundleMinifiedPath)) {
|
||||||
|
console.info('Bundle has not changed - skipping minifying...');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
console.info(`Minifying bundle: ${this.bundleName}...`);
|
console.info(`Minifying bundle: ${this.bundleName}...`);
|
||||||
|
|
||||||
await execa('yarn', [
|
await execa('yarn', [
|
||||||
'run', 'uglifyjs',
|
'run', 'uglifyjs',
|
||||||
'--compress',
|
'--compress',
|
||||||
'-o', this.bundleMinifiedPath,
|
'-o', this.bundleMinifiedPath,
|
||||||
this.bundleOutputPath,
|
this.bundleOutputPath,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
await writeFile(md5Path, newMd5, 'utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleErrors(err: Error | undefined | null, stats: webpack.Stats | undefined): boolean {
|
private handleErrors(err: Error | undefined | null, stats: webpack.Stats | undefined): boolean {
|
||||||
|
|
|
@ -4713,6 +4713,7 @@ __metadata:
|
||||||
jsc-android: 241213.1.0
|
jsc-android: 241213.1.0
|
||||||
jsdom: 20.0.0
|
jsdom: 20.0.0
|
||||||
md5: 2.3.0
|
md5: 2.3.0
|
||||||
|
md5-file: 5.0.0
|
||||||
metro-react-native-babel-preset: 0.67.0
|
metro-react-native-babel-preset: 0.67.0
|
||||||
nodemon: 2.0.20
|
nodemon: 2.0.20
|
||||||
prop-types: 15.8.1
|
prop-types: 15.8.1
|
||||||
|
|
Loading…
Reference in New Issue