Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default () => ({
// Env
dev: Boolean(env.dev),
test: Boolean(env.test),
debug: undefined, // = dev
env: {},
// Mode
mode: 'universal',
modern: undefined,
// Globals
globalName: `nuxt`,
globals: {
id: globalName => `__${globalName}`,
nuxt: globalName => `$${globalName}`,
context: globalName => `__${globalName.toUpperCase()}__`,
pluginPrefix: globalName => globalName,
readyCallback: globalName => `on${capitalize(globalName)}Ready`,
loadedCallback: globalName => `_on${capitalize(globalName)}Loaded`
function createConsola () {
// Log level
let level = env.debug ? 4 : 3
if (process.env.CONSOLA_LEVEL) {
level = parseInt(process.env.CONSOLA_LEVEL) || level
}
// Create new consola instance
const consola = new Consola({
level,
reporters: [
(env.ci || env.test)
? new BasicReporter()
: new FancyReporter()
]
})
// Expose constructors
consola.Consola = Consola
consola.BasicReporter = BasicReporter
consola.FancyReporter = FancyReporter
consola.JSONReporter = JSONReporter
consola.WinstonReporter = WinstonReporter
return consola
}
buildDir: '.nuxt',
nuxtDir,
nuxtAppDir: path.resolve(nuxtDir, 'lib', 'app'),
modulesDir: ['node_modules'], // ~> relative to options.rootDir
// Ignore
ignorePrefix: '-',
ignore: [
'**/*.test.*',
'**/*.spec.*'
],
extensions: [],
build: {
quiet: Boolean(env.ci || env.test),
analyze: false,
profile: process.argv.includes('--profile'),
extractCSS: false,
cssSourceMap: undefined,
ssr: undefined,
parallel: false,
cache: false,
publicPath: '/_nuxt/',
filenames: {
// { isDev, isClient, isServer }
app: ({ isDev }) => isDev ? '[name].js' : '[chunkhash].js',
chunk: ({ isDev }) => isDev ? '[name].js' : '[chunkhash].js',
css: ({ isDev }) => isDev ? '[name].js' : '[contenthash].css',
img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[hash:7].[ext]',
font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[hash:7].[ext]',
video: ({ isDev }) => isDev ? '[path][name].[ext]' : 'videos/[hash:7].[ext]'
export function showBanner (nuxt, showMemoryUsage = true) {
if (env.test) {
return
}
if (env.minimalCLI) {
for (const listener of nuxt.server.listeners) {
consola.info('Listening on: ' + listener.url)
}
return
}
const titleLines = []
const messageLines = []
// Name and version
const { bannerColor } = nuxt.options.cli
titleLines.push(`${chalk[bannerColor].bold('Nuxt.js')} ${nuxt.constructor.version}`)
// Validation errors
const { validate } = options.server.routes
if (validate.failAction === undefined) {
validate.failAction = async (_, __, err) => {
if (options.dev) {
consola.error(err + '')
}
throw err
}
}
return options
}
Options.defaults = {
dev: !env.production && !env.test && !env.ci,
relativeTo: '',
routeTable: undefined,
registrations: [],
routes: [],
esm: {},
prefix: '/',
nodemon: {},
devErrors: {
showErrors: undefined,
useYouch: true,
toTerminal: false
},
server: {
cache: null,
port: process.env.PORT || 3000,
host: process.env.HOST || '0.0.0.0',
export default () => ({
quiet: Boolean(env.ci || env.test),
analyze: false,
profile: process.argv.includes('--profile'),
extractCSS: false,
crossorigin: undefined,
cssSourceMap: undefined,
ssr: undefined,
parallel: false,
cache: false,
standalone: false,
publicPath: '/_nuxt/',
filenames: {
// { isDev, isClient, isServer }
app: ({ isDev, isModern }) => isDev ? `${isModern ? 'modern-' : ''}[name].js` : '[chunkhash].js',
chunk: ({ isDev, isModern }) => isDev ? `${isModern ? 'modern-' : ''}[name].js` : '[chunkhash].js',
css: ({ isDev }) => isDev ? '[name].css' : '[contenthash].css',
img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[hash:7].[ext]',
setupFilesAfterEnv: ['./test/utils/setup'],
coverageDirectory: './coverage',
collectCoverageFrom: [
'packages/**/*.js',
'!**/blueprint/**',
'!**/test/**'
],
moduleNameMapper: {
"@/(.*)$": "/test/$1",
"~/(.*)$": "/src/$1",
// TODO: enable this again when we re-introduce a build step
"^pressModule$": false && stdEnv.ci ? "/" : "/distributions/nuxt-press/src"
},
transform: {
'^.+\\.js$': 'babel-jest',
'^.+\\.vue$': 'vue-jest'
},
moduleFileExtensions: [
'js',
'json'
],
reporters: [
'default',
// ['jest-junit', { outputDirectory: 'reports/junit' }]
]
plugins.push(...(buildOptions.plugins || []))
plugins.push(new WarningIgnorePlugin(this.warningIgnoreFilter()))
// Build progress indicator
plugins.push(new WebpackBar({
name: this.name,
color: this.colors[this.name],
reporters: [
'basic',
'fancy',
'profile',
'stats'
],
basic: !buildOptions.quiet && env.minimalCLI,
fancy: !buildOptions.quiet && !env.minimalCLI,
profile: !buildOptions.quiet && buildOptions.profile,
stats: !buildOptions.quiet && !this.dev && buildOptions.stats,
reporter: {
change: (_, { shortPath }) => {
if (!this.isServer) {
nuxt.callHook('bundler:change', shortPath)
}
},
done: (buildContext) => {
if (buildContext.hasErrors) {
nuxt.callHook('bundler:error')
}
},
allDone: () => {
nuxt.callHook('bundler:done')
},
export function showBanner (nuxt, showMemoryUsage = true) {
if (env.test) {
return
}
if (env.minimalCLI) {
for (const listener of nuxt.server.listeners) {
consola.info('Listening on: ' + listener.url)
}
return
}
const titleLines = []
const messageLines = []
// Name and version
const { bannerColor } = nuxt.options.cli
titleLines.push(`${chalk[bannerColor].bold('Nuxt.js')} ${nuxt.constructor.version}`)
// Running mode
titleLines.push(`Running in ${nuxt.options.dev ? chalk.bold.blue('development') : chalk.bold.green('production')} mode (${chalk.bold(nuxt.options.mode)})`)
plugins.push(...(buildOptions.plugins || []))
plugins.push(new WarningIgnorePlugin(this.warningIgnoreFilter()))
// Build progress indicator
plugins.push(new WebpackBar({
name: this.name,
color: this.colors[this.name],
reporters: [
'basic',
'fancy',
'profile',
'stats'
],
basic: !buildOptions.quiet && env.minimalCLI,
fancy: !buildOptions.quiet && !env.minimalCLI,
profile: !buildOptions.quiet && buildOptions.profile,
stats: !buildOptions.quiet && !this.dev && buildOptions.stats,
reporter: {
change: (_, { shortPath }) => {
if (!this.isServer) {
nuxt.callHook('bundler:change', shortPath)
}
},
done: (buildContext) => {
if (buildContext.hasErrors) {
nuxt.callHook('bundler:error')
}
},
allDone: () => {
nuxt.callHook('bundler:done')