我有一个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"
}
}它应该工作,还是我必须实现更多的东西?
发布于 2019-07-01 19:54:24
我的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;
}
});发布于 2019-02-20 04:36:27
精简版本仅在production模式下创建,因为缩减代码需要时间。
为了缩小您的生产模式,您应该在运行next build时将NODE_ENV设置为 production 。
您可以通过将npm构建脚本更改为:NODE_ENV=production next build来完成。
https://stackoverflow.com/questions/54774048
复制相似问题