mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
feat: init
This commit is contained in:
31
webpage/plugins/with-goodwrites.js
Normal file
31
webpage/plugins/with-goodwrites.js
Normal file
@@ -0,0 +1,31 @@
|
||||
exports.withGoodwrites = (nextConfig = {}) => ({
|
||||
...nextConfig,
|
||||
webpack(config, options) {
|
||||
const { isServer, dev } = options;
|
||||
let outputPath = "";
|
||||
if (isServer && dev) {
|
||||
outputPath = "../";
|
||||
} else if (isServer) {
|
||||
outputPath = "../../";
|
||||
}
|
||||
config.module.rules.push({
|
||||
test: /article.yml$/,
|
||||
use: [
|
||||
{
|
||||
loader: require.resolve("@morten-olsen/goodwrites-webpack-loader"),
|
||||
options: {
|
||||
publicPath: `${
|
||||
nextConfig.assetPrefix || nextConfig.basePath || ""
|
||||
}/_next/static/assets/`,
|
||||
outputPath: `${outputPath}static/assets/`,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
if (typeof nextConfig.webpack === "function") {
|
||||
return nextConfig.webpack(config, options);
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
});
|
||||
46
webpage/plugins/with-images.js
Normal file
46
webpage/plugins/with-images.js
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
exports.withImages = (nextConfig = {}) => ({
|
||||
...nextConfig,
|
||||
webpack(config, options) {
|
||||
nextConfig = Object.assign(
|
||||
{ inlineImageLimit: false, assetPrefix: "" },
|
||||
nextConfig
|
||||
);
|
||||
|
||||
const { isServer, dev } = options;
|
||||
let outputPath = "";
|
||||
if (isServer && dev) {
|
||||
outputPath = "../";
|
||||
} else if (isServer) {
|
||||
outputPath = "../../";
|
||||
}
|
||||
|
||||
config.module.rules.push({
|
||||
test: /\.(jpe?g|png|gif|ico|webp|jp2|url|svg)$/,
|
||||
// Next.js already handles url() in css/sass/scss files
|
||||
// issuer: /\.\w+(?<!(s?c|sa)ss)$/i, // commented out because of a bug with require.context load https://github.com/webpack/webpack/issues/9309
|
||||
use: [
|
||||
{
|
||||
loader: require.resolve("url-loader"),
|
||||
options: {
|
||||
limit: nextConfig.inlineImageLimit,
|
||||
fallback: require.resolve("file-loader"),
|
||||
publicPath: `${
|
||||
nextConfig.assetPrefix || nextConfig.basePath || ""
|
||||
}/_next/static/images/`,
|
||||
outputPath: `${outputPath}static/images/`,
|
||||
name: "[name]-[hash].[ext]",
|
||||
esModule: nextConfig.esModule || false,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
if (typeof nextConfig.webpack === "function") {
|
||||
return nextConfig.webpack(config, options);
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
});
|
||||
|
||||
18
webpage/plugins/with-markdown.js
Normal file
18
webpage/plugins/with-markdown.js
Normal file
@@ -0,0 +1,18 @@
|
||||
exports.withMarkdown = (nextConfig = {}) => ({
|
||||
...nextConfig,
|
||||
webpack(config, options) {
|
||||
config.module.rules.push({
|
||||
test: /\.md$/,
|
||||
use: [
|
||||
{
|
||||
loader: require.resolve("@morten-olsen/markdown-loader"),
|
||||
},
|
||||
],
|
||||
});
|
||||
if (typeof nextConfig.webpack === "function") {
|
||||
return nextConfig.webpack(config, options);
|
||||
}
|
||||
|
||||
return config;
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user