mirror of
https://github.com/moebooru/moebooru
synced 2025-08-22 01:47:48 +00:00
Update to the latest libraries
Also changed mapping path for coffees
This commit is contained in:
parent
9e21dc1e81
commit
e610e05337
48
build.js
48
build.js
@ -6,7 +6,7 @@ import esbuild from 'esbuild';
|
|||||||
import coffeeScriptPlugin from 'esbuild-coffeescript';
|
import coffeeScriptPlugin from 'esbuild-coffeescript';
|
||||||
import { lessLoader } from 'esbuild-plugin-less';
|
import { lessLoader } from 'esbuild-plugin-less';
|
||||||
import fsPromises from 'fs/promises';
|
import fsPromises from 'fs/promises';
|
||||||
import glob from 'glob';
|
import { globSync } from 'glob';
|
||||||
|
|
||||||
const outdir = 'app/assets/builds';
|
const outdir = 'app/assets/builds';
|
||||||
|
|
||||||
@ -41,15 +41,13 @@ const plugins = [
|
|||||||
const outfileBabel = `${outdir}/${filename}`;
|
const outfileBabel = `${outdir}/${filename}`;
|
||||||
result.map.sources = result.map.sources
|
result.map.sources = result.map.sources
|
||||||
// CoffeeScript sourcemap and Esbuild sourcemap combined generates duplicated source paths
|
// CoffeeScript sourcemap and Esbuild sourcemap combined generates duplicated source paths
|
||||||
.map((path) => path.replace(/\.\.\/\.\.\/javascript(\/.+)?\/app\/javascript\//, '../app/javascript/'));
|
.map((path) => path.replace(/\.\.\/\.\.\/javascript(\/.+)?\/app\/javascript\//, '../../javascript/'));
|
||||||
const resultMap = JSON.stringify(result.map);
|
const resultMap = JSON.stringify(result.map);
|
||||||
const resultMapHash = createHash('sha256').update(resultMap).digest('hex');
|
const resultMapHash = createHash('sha256').update(resultMap).digest('hex');
|
||||||
|
|
||||||
return Promise.all([
|
// add hash so it matches sprocket output
|
||||||
// add hash so it matches sprocket output
|
fsPromises.writeFile(outfileBabel, `${result.code}\n//# sourceMappingURL=${filename}-${resultMapHash}.map`);
|
||||||
fsPromises.writeFile(outfileBabel, `${result.code}\n//# sourceMappingURL=${filename}-${resultMapHash}.map`),
|
fsPromises.writeFile(`${outfileBabel}.map`, JSON.stringify(result.map));
|
||||||
fsPromises.writeFile(`${outfileBabel}.map`, JSON.stringify(result.map))
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -64,6 +62,17 @@ const plugins = [
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'log',
|
||||||
|
setup (build) {
|
||||||
|
build.onStart(() => {
|
||||||
|
console.log(new Date(), 'Build started');
|
||||||
|
});
|
||||||
|
build.onEnd(() => {
|
||||||
|
console.log(new Date(), 'Build finished');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -72,26 +81,21 @@ const options = {
|
|||||||
watch: args.includes('--watch'),
|
watch: args.includes('--watch'),
|
||||||
analyze: args.includes('--analyze')
|
analyze: args.includes('--analyze')
|
||||||
};
|
};
|
||||||
const watch = options.watch
|
|
||||||
? {
|
|
||||||
onRebuild (error) {
|
|
||||||
if (error == null) {
|
|
||||||
console.log(new Date(), 'Rebuild succeeded');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: false;
|
|
||||||
|
|
||||||
esbuild.build({
|
const ctx = await esbuild.context({
|
||||||
bundle: true,
|
bundle: true,
|
||||||
entryPoints: glob.sync('app/javascript/*.*'),
|
entryPoints: globSync('app/javascript/*.*'),
|
||||||
external: ['*.gif', '*.png'],
|
external: ['*.gif', '*.png'],
|
||||||
metafile: options.analyze,
|
metafile: options.analyze,
|
||||||
nodePaths: ['app/javascript'],
|
nodePaths: ['app/javascript'],
|
||||||
outdir,
|
outdir,
|
||||||
plugins,
|
plugins,
|
||||||
resolveExtensions: ['.coffee', '.js'],
|
resolveExtensions: ['.coffee', '.js'],
|
||||||
sourcemap: 'external',
|
sourcemap: 'external'
|
||||||
watch
|
});
|
||||||
}).then(() => console.log(new Date(), 'Build succeeded'))
|
|
||||||
.catch((e) => console.debug(e));
|
if (options.watch) {
|
||||||
|
ctx.watch();
|
||||||
|
} else {
|
||||||
|
ctx.rebuild();
|
||||||
|
}
|
||||||
|
7746
package-lock.json
generated
7746
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -2,14 +2,14 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.17.0",
|
"@babel/core": "^7.17.0",
|
||||||
"@babel/preset-env": "^7.16.11",
|
"@babel/preset-env": "^7.16.11",
|
||||||
"@rails/ujs": "^7.0.1",
|
"@rails/ujs": "7.1.3-4",
|
||||||
"autocompleter": "^6.1.2",
|
"autocompleter": "^9.3.2",
|
||||||
"coffeescript": "2.6.1",
|
"coffeescript": "^2.7.0",
|
||||||
"cropperjs": "^1.5.12",
|
"cropperjs": "^1.5.12",
|
||||||
"esbuild": "^0.14.16",
|
"esbuild": "^0.24.0",
|
||||||
"esbuild-coffeescript": "^2.0.0",
|
"esbuild-coffeescript": "^2.0.0",
|
||||||
"esbuild-plugin-less": "^1.1.6",
|
"esbuild-plugin-less": "^1.1.6",
|
||||||
"glob": "^7.2.0",
|
"glob": "^11.0.0",
|
||||||
"jquery": "^3.6.0",
|
"jquery": "^3.6.0",
|
||||||
"js-cookie": "^3.0.1",
|
"js-cookie": "^3.0.1",
|
||||||
"mousetrap": "^1.6.5",
|
"mousetrap": "^1.6.5",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user