:)
看看下面的配置。注意module.exports = (ctx) => ({... 这是我编译它的诀窍。我尝试了所有方法,包括通过.babelrc 发布 css 加载程序,但没有任何效果。
postcss.config.js
module.exports = (ctx) => ({
plugins: [
require('postcss-import'),
require('postcss-nested'),
require('postcss-easing-gradients'),
require('postcss-selector-not'),
require('postcss-flexbugs-fixes'),
require('postcss-custom-media')({
customMedia: {
'--breakpoint-not-small' : 'screen and (min-width: 30em)',
'--breakpoint-medium ': 'screen and (min-width: 30em) and (max-width: 60em)',
'--breakpoint-large ': 'screen and (min-width: 60em)',
}
}),
require('postcss-preset-env')({ stage: 1 }),
require('tailwindcss'),
require('autoprefixer')
]
})
next.config.js
/**
* next.config.js
* Next JS configuration file
* The following helps to use multiple plugins
* @see https://github.com/JerryCauser/next-compose
*/
/**
* Using Fonts
* @see https://github.com/rohanray/next-fonts
* Environment variables
* @see https://stackoverflow.com/questions/50416138/nextjs-set-dynamic-environment-variables-at-the-start-of-the-application
*/
/**
* Exclude tests and stories from being compiled.
* @see https://github.com/zeit/next.js/issues/1914
* via
* excludeFile: ... (see below)
*/
const withPlugins = require('next-compose-plugins')
const withImages = require('next-images')
const withFonts = require('next-fonts')
const optimizedImages = require('next-optimized-images')
const withCSS = require('@zeit/next-css')
console.log('NextJs Config Environment:', process.env.NODE_ENV)
const nextConfig = {
distDir: '_next',
// serverRuntimeConfig: { // Will only be available on the server side
// wordpressApiUrl: process.env.WORDPRESS_API_URL
// },
// publicRuntimeConfig: { // Will be available on both server and client
// staticFolder: '/public',
// port: 8081 // The server port
// },
// pageExtensions: ['jsx', 'js'],
// Removes the [BABEL] Note: The code generator has deoptimised the styling of
compact: true,
webpack: (config, options) => {
const { isServer, buildId, dev } = options
// Fixes npm packages that depend on `fs` module
// config.node = {
// fs: 'empty',
// };
if (dev) {
// Skip tests and stories from being compiled during development
// Note: This speeds up compilation.
config.module.rules.push(
{
test: /\.(spec,test,stories)\.(js|jsx)$/,
loader: 'ignore-loader'
},
)
}
return config
},
// Client-side environment variables
env: {
...
}
}
module.exports = withPlugins([
[withImages, {}],
[optimizedImages, {}],
[withFonts, {}],
[withCSS, {}],
], nextConfig)
.babelrc
// .babelrc
// @see https://nextjs.org/docs/advanced-features/customizing-babel-config for more.
{
"ignore": [ "node_modules/**" ],
"presets": [
[
"next/babel"
]
],
"plugins": [
"inline-react-svg"
]
}