Reputation: 915
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?
Upvotes: 4
Views: 3434
Reputation: 915
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.
Upvotes: 1