mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
const path = require('path');
|
|
const withLatex = (nextConfig = {}) => {
|
|
return Object.assign({}, nextConfig, {
|
|
webpack(config, options) {
|
|
const {isServer, dev} = options;
|
|
let outputPath = '';
|
|
if (isServer && dev) {
|
|
outputPath = "../";
|
|
} else if (isServer) {
|
|
outputPath = "../../";
|
|
}
|
|
config.module.rules.push({
|
|
test: /\.gen.yml$/,
|
|
use: [{
|
|
loader: require.resolve('./webpack.js'),
|
|
options: {
|
|
|
|
publicPath: `${nextConfig.assetPrefix || nextConfig.basePath || ''}/_next/static/images/`,
|
|
outputPath: `${outputPath}static/images/`,
|
|
name: (name) => {
|
|
const fileName = path.basename(name);
|
|
const parts = fileName.split('.');
|
|
parts.pop();
|
|
const ext = parts.pop();
|
|
|
|
return `${parts.join('.')}.[hash].${ext}`;
|
|
},
|
|
esModule: nextConfig.esModule || false,
|
|
},
|
|
}],
|
|
});
|
|
if (typeof nextConfig.webpack === "function") {
|
|
return nextConfig.webpack(config, options);
|
|
}
|
|
|
|
return config;
|
|
},
|
|
});
|
|
}
|
|
|
|
module.exports = withLatex;
|