How i can set target: 'serverless' in file next.config.js #11279
Answered
by
approached
approached
asked this question in
Help
-
Hi @ all, i have const withSass = require("@zeit/next-sass");
const tailwindCss = require("tailwindcss");
module.exports = withSass({
webpack(config, options) {
const rules = [{
test: /\.scss$/,
use: [
{
loader: "postcss-loader",
options: {
ident: "postcss",
plugins: [tailwindCss("./tailwind.config.js")]
}
},
{loader: "sass-loader"}
]
}
];
return {
...config,
module: {
...config.module,
rules: [...config.module.rules, ...rules]
}
};
}
},
); For serverless deployment me need to set: module.exports = {
target: "serverless"
}; But how can i do it? By the way how i can debug the module.exports output? |
Beta Was this translation helpful? Give feedback.
Answered by
approached
Mar 24, 2020
Replies: 2 comments
-
Do this: const withSass = require("@zeit/next-sass");
const tailwindCss = require("tailwindcss");
module.exports = withSass({
webpack(config, options) {
const rules = [{
test: /\.scss$/,
use: [
{
loader: "postcss-loader",
options: {
ident: "postcss",
plugins: [tailwindCss("./tailwind.config.js")]
}
},
{loader: "sass-loader"}
]
}
];
return {
...config,
module: {
...config.module,
rules: [...config.module.rules, ...rules]
}
};
}
},
target: 'serverless'
); N.B. Deployments to ZEIT Now will automatically enable this target. You do not need to opt-into it yourself, but you can. For "debugging", you could do something like this: const withSass = require("@zeit/next-sass");
const tailwindCss = require("tailwindcss");
const config = withSass({
webpack(config, options) {
const rules = [{
test: /\.scss$/,
use: [
{
loader: "postcss-loader",
options: {
ident: "postcss",
plugins: [tailwindCss("./tailwind.config.js")]
}
},
{loader: "sass-loader"}
]
}
];
return {
...config,
module: {
...config.module,
rules: [...config.module.rules, ...rules]
}
};
}
},
);
// check our config
console.log(config)
module.exports = config |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you so much for the clearness. const withSass = require("@zeit/next-sass");
const tailwindCss = require("tailwindcss");
module.exports = withSass({
webpack(config, options) {
const rules = [{
test: /\.scss$/,
use: [
{
loader: "postcss-loader",
options: {
ident: "postcss",
plugins: [tailwindCss("./tailwind.config.js")]
}
},
{loader: "sass-loader"}
]
}
];
return {
...config,
module: {
...config.module,
rules: [...config.module.rules, ...rules]
}
};
}
target: 'serverless'
},
); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
approached
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much for the clearness.
This code works for me good: