mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-24 22:55:13 +00:00
3f1d634fb7
* Minor consistency enhancements * Arrow parenthesis consistency * Change linting rule * Fix typo * Update .eslintrc.js to only require parens for blocks * Update style according to brace-only suggestion * Remove --fix from lint * Tweak no-loading time (failing test) * Tweak no-loading time (failing test) (2) * Tweak no-loading time (failing test) (3) * Tweak no-loading time (failing test) (4) * Tweak no-loading time (failing test) (5)
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import chalk from 'chalk'
|
|
|
|
const prefix = `[vue-server-renderer-webpack-plugin]`
|
|
export const warn = msg => console.error(chalk.red(`${prefix} ${msg}\n`)) // eslint-disable-line no-console
|
|
export const tip = msg => console.log(chalk.yellow(`${prefix} ${msg}\n`)) // eslint-disable-line no-console
|
|
|
|
export const validate = (compiler) => {
|
|
if (compiler.options.target !== 'node') {
|
|
warn('webpack config `target` should be "node".')
|
|
}
|
|
|
|
if (compiler.options.output && compiler.options.output.libraryTarget !== 'commonjs2') {
|
|
warn('webpack config `output.libraryTarget` should be "commonjs2".')
|
|
}
|
|
|
|
if (!compiler.options.externals) {
|
|
tip(
|
|
'It is recommended to externalize dependencies in the server build for ' +
|
|
'better build performance.'
|
|
)
|
|
}
|
|
}
|
|
|
|
export const onEmit = (compiler, name, hook) => {
|
|
if (compiler.hooks) {
|
|
// Webpack >= 4.0.0
|
|
compiler.hooks.emit.tapAsync(name, hook)
|
|
} else {
|
|
// Webpack < 4.0.0
|
|
compiler.plugin('emit', hook)
|
|
}
|
|
}
|
|
|
|
export const isJS = file => /\.js(\?[^.]+)?$/.test(file)
|
|
|
|
export const isCSS = file => /\.css(\?[^.]+)?$/.test(file)
|