Advertisement
crutch12

Untitled

Mar 4th, 2021
836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. next-plugins/next-ts-checker.js
  2.  
  3. /* eslint-disable @typescript-eslint/no-var-requires */
  4. const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
  5.  
  6. /**
  7.  * Next-плагин для подключение вывода TS ошибок в консоль в dev режиме
  8.  * @see https://github.com/cyrilwanner/next-compose-plugins#phases
  9.  * @see https://github.com/vercel/next.js/pull/13428#issuecomment-655193665
  10.  */
  11. module.exports = (nextConfig = {}) => {
  12.   return Object.assign({}, nextConfig, {
  13.     // define in which phases this plugin should get applied.
  14.     // you can also use multiple phases or negate them.
  15.     // however, users can still overwrite them in their configuration if they really want to.
  16.     phases: [PHASE_DEVELOPMENT_SERVER],
  17.  
  18.     webpack(config, options) {
  19.       // https://gist.github.com/dutchenkoOleg/c561d59c1ec9dbcc9414f6e4274c706d
  20.       if (!options.isServer) {
  21.         const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
  22.         config.plugins.push(new ForkTsCheckerWebpackPlugin());
  23.       }
  24.  
  25.       if (typeof nextConfig.webpack === 'function') {
  26.         return nextConfig.webpack(config, options);
  27.       }
  28.  
  29.       return config;
  30.     },
  31.   });
  32. };
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement