2020-07-02 13:02:35 +00:00
|
|
|
/**
|
|
|
|
* This file is based on Vue.js (MIT) webpack plugins
|
|
|
|
* https://github.com/vuejs/vue/blob/dev/src/server/webpack-plugin/util.js
|
|
|
|
*/
|
|
|
|
|
2022-02-16 21:34:32 +00:00
|
|
|
import { logger } from '@nuxt/kit'
|
2022-08-26 15:47:29 +00:00
|
|
|
import type { Compiler } from 'webpack'
|
2020-07-02 13:02:35 +00:00
|
|
|
|
2022-08-26 15:47:29 +00:00
|
|
|
export const validate = (compiler: Compiler) => {
|
2020-07-02 13:02:35 +00:00
|
|
|
if (compiler.options.target !== 'node') {
|
2022-02-16 21:34:32 +00:00
|
|
|
logger.warn('webpack config `target` should be "node".')
|
2020-07-02 13:02:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!compiler.options.externals) {
|
2022-02-16 21:34:32 +00:00
|
|
|
logger.info(
|
2020-07-02 13:02:35 +00:00
|
|
|
'It is recommended to externalize dependencies in the server build for ' +
|
|
|
|
'better build performance.'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-28 12:00:39 +00:00
|
|
|
const isJSRegExp = /\.[cm]?js(\?[^.]+)?$/
|
2020-07-02 13:02:35 +00:00
|
|
|
|
2022-08-26 15:47:29 +00:00
|
|
|
export const isJS = (file: string) => isJSRegExp.test(file)
|
2020-07-02 13:02:35 +00:00
|
|
|
|
2022-08-26 15:47:29 +00:00
|
|
|
export const extractQueryPartJS = (file: string) => isJSRegExp.exec(file)?.[1]
|
2020-07-02 13:02:35 +00:00
|
|
|
|
2022-08-26 15:47:29 +00:00
|
|
|
export const isCSS = (file: string) => /\.css(\?[^.]+)?$/.test(file)
|
2021-02-17 19:39:02 +00:00
|
|
|
|
2022-08-26 15:47:29 +00:00
|
|
|
export const isHotUpdate = (file: string) => file.includes('hot-update')
|