29
loading...
This website collects cookies to deliver better user experience
npx create-next-app
and just add the name to it$ npx create-next-app webpack-next
cd webpack-next
npm run dev
webpack.config.js
direct. As you see in the documentation:module.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Important: return the modified config
return config
},
}
next.config.js
you are supposed to restart the dev sever manually. I'm suspicious of auto restarts, so even if it were restarting on it's own, as NuxtJS does, I would restart manually from time to time anyway..my-files
to be loaded as text:module.exports = {
reactStrictMode: true, // was there by default
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.module.rules.push({
test: /\.my-file$/i,
loader: "raw-loader",
});
// Important: return the modified config
return config;
},
};
config.module.rules
. Otherwise, if we were overriding the whole array, would drop all loaders specified by Next.js./pages/test.my-file
:Test content
import test from "./test.my-file";
export default function Home() {
return <div>{test}</div>;
}
raw-loader
first: