Advertisement
ahmadandika

next js config

Sep 16th, 2020
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const withSass = require('@zeit/next-sass');
  2. const withCSS = require('@zeit/next-css');
  3. const withFonts = require('next-fonts');
  4. const withPlugins = require('next-compose-plugins');
  5. const optimizedImages = require('next-optimized-images');
  6. const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
  7. const webpack = require('webpack');
  8. const DotEnv = require('dotenv');
  9. const path = require('path');
  10. const withBabelMinify = require('next-babel-minify')();
  11.  
  12. DotEnv.config();
  13.  
  14. module.exports = withPlugins(
  15.   [
  16.     [
  17.       optimizedImages,
  18.       {
  19.         inlineImageLimit: 8192,
  20.         imagesFolder: 'images',
  21.         imagesName: '[name]-[hash].[ext]',
  22.         handleImages: ['jpeg', 'jpg', 'png', 'svg', 'webp', 'gif', 'ico'],
  23.         optimizeImages: true,
  24.         optimizeImagesInDev: false,
  25.         mozjpeg: {
  26.           quality: 80
  27.         },
  28.         optipng: {
  29.           optimizationLevel: 3
  30.         },
  31.         pngquant: false,
  32.         gifsicle: {
  33.           interlaced: true,
  34.           optimizationLevel: 3
  35.         },
  36.         webp: {
  37.           preset: 'default',
  38.           quality: 75
  39.         }
  40.       }
  41.     ],
  42.     [withCSS],
  43.     [withFonts],
  44.     [withSass],
  45.     [withBabelMinify]
  46.   ],
  47.   {
  48.     exportPathMap() {
  49.       return {
  50.         '/': { page: '/' }
  51.       };
  52.     },
  53.     webpack: config => {
  54.       config.plugins.push(new webpack.EnvironmentPlugin(process.env));
  55.       config.resolve.alias = {
  56.         ...config.resolve.alias,
  57.         '@actions': path.resolve('src/store/actions'),
  58.         '@components': path.resolve('src/components'),
  59.         '@containers': path.resolve('src/containers'),
  60.         '@configs': path.resolve('src/configs'),
  61.         '@helpers': path.resolve('src/helpers'),
  62.         '@images': path.resolve('src/assets/images'),
  63.         '@styles': path.resolve('src/assets/styles'),
  64.         '@layout': path.resolve('src/layout'),
  65.         '@reducers': path.resolve('src/store/reducers')
  66.       };
  67.       config.optimization.minimizer = [];
  68.       config.optimization.minimizer.push(new OptimizeCSSAssetsPlugin({}));
  69.       return config;
  70.     }
  71.   }
  72. );
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement