Created
May 11, 2018 06:14
-
-
Save stramel/bfcf2c8d2572f92a344bfc6247a51f08 to your computer and use it in GitHub Desktop.
Next.js v6 configs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"env": { | |
"development": { | |
"presets": ["next/babel"] | |
}, | |
"production": { | |
"presets": ["next/babel"] | |
}, | |
"test": { | |
"presets": [ | |
[ | |
"next/babel", | |
{ | |
"preset-env": { | |
"modules": "commonjs" | |
} | |
} | |
] | |
] | |
} | |
}, | |
"plugins": [ | |
[ | |
"module-resolver", | |
{ | |
"root": ["./"], | |
"alias": {} | |
} | |
], | |
[ | |
"styled-components", | |
{ | |
"ssr": true, | |
"displayName": true, | |
"preprocess": false | |
} | |
] | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webpack = require('webpack') | |
const cfg = require('./config') | |
const { withPlugins, optional } = require('next-compose-plugins') | |
const withCSS = require('@zeit/next-css') | |
const withBundleAnalyzer = require('@zeit/next-bundle-analyzer') | |
const withProgress = require('next-progressbar') | |
const nextConfig = { | |
webpack: (config, { dev, isServer }) => { | |
if (!isServer) { | |
// Fixes npm packages that depend on `fs` module | |
config.node = { | |
fs: 'empty', | |
} | |
} | |
config.plugins.push(new webpack.DefinePlugin({ | |
'process.env.API_URL': JSON.stringify(cfg.api.url), | |
'process.env.API_REMOTE': JSON.stringify(cfg.api.remote), | |
'process.env.AUTH_URL': JSON.stringify(cfg.auth.url), | |
})) | |
config.plugins.push(new webpack.IgnorePlugin(/(?:\/tests|__mocks)/)) | |
config.plugins.push(new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /(ru)/)) | |
if (dev) { | |
config.output.crossOriginLoading = 'anonymous' | |
} | |
return config | |
}, | |
distDir: 'dist', | |
} | |
module.exports = withPlugins( | |
[ | |
[withCSS], | |
[ | |
withBundleAnalyzer, | |
{ | |
analyzeServer: ['server', 'both'].includes(process.env.BUNDLE_ANALYZE), | |
analyzeBrowser: ['browser', 'both'].includes(process.env.BUNDLE_ANALYZE), | |
bundleAnalyzerConfig: { | |
server: { | |
analyzerPort: 8888, | |
}, | |
browser: { | |
analyzerPort: 8000, | |
}, | |
}, | |
}, | |
], | |
[withProgress], | |
], | |
nextConfig, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment