我有一个 nextjs 网站。
我的 common.js 和我的 custom.scss 不会被 next 缩小。
我在 next.config.js 中尝试了下一个:
const withSass = require('@zeit/next-sass')
const withOptimizedImages = require('next-optimized-images');
const withTypescript = require('@zeit/next-typescript')
module.exports = withSass({minified:true},withOptimizedImages(withTypescript()))
我的 .babelrc
{
"presets": [
"next/babel",
"@zeit/next-typescript/babel",
"minify"
]
}
我的 tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"jsx": "preserve",
"lib": [
"dom",
"es2017"
],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"preserveConstEnums": true,
"removeComments": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "esnext"
}
}
它应该工作还是我必须实现更多的东西?
最佳答案
我的 next.config.js:
const withCSS = require("@zeit/next-css");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
module.exports =
withCSS({
webpack(config, options) {
config.optimization.minimizer = [];
config.optimization.minimizer.push(new OptimizeCSSAssetsPlugin({}));
return config;
}
});
关于reactjs - 缩小/优化 NextJS 站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54774048/