4

I am trying to add sass support and an webpack image loader for my next application together with support for exported routes. I am having problems with how to compose the config file. I don't understand how the sass plugin gets added to the webpack config, and how to compose and export the next.config.js function.

const fetch = require('isomorphic-unfetch');
var Prismic = require('prismic-javascript');
const withSass = require('@zeit/next-sass')

var apiEndpoint = 'https://apiendpoint/api/v2';

module.exports =

withSass({
    async exportPathMap() {

  const response = await Prismic.getApi(apiEndpoint)
    .then(function (api) {
      return api.query(
        Prismic.Predicates.at('document.type', 'post')
      );
    })
    .then(
      function (response) {
        return response.results
      },
      function (err) {
        console.log('Something went wrong: ', err);
      }
    );

  // tranform the list of posts into a map of pages with the pathname `/post/:id`
  const pages = await response.reduce((pages, post) =>

    Object.assign({}, pages, {
      [`/post/${post.id}`]: {
        page: '/post',
        query: {
          id: post.id
        }
      }
    }), {},

  )


  // combine the map of post pages with the home
  return Object.assign({}, pages, {
    '/': {
      page: '/'
    }
  })
 }
})

Can anyone help?

1

1 Answer 1

1

It's an old question, but seeing that people are searching for this question I figured that I should post an answer. I would recommend using https://github.com/cyrilwanner/next-compose-plugins Its a very simple API and much cleaner. Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.