Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.exclude
.add(/node_modules/)
.add(path.dirname(require.resolve('@vue/cli-service')))
.end()
.test(/\.(vue|(j|t)sx?)$/)
.use('eslint-loader')
.loader(require.resolve('eslint-loader'))
.options({
extensions,
cache: true,
cacheIdentifier,
emitWarning: allWarnings,
// only emit errors in production mode.
emitError: allErrors,
eslintPath: path.dirname(
resolveModule('eslint/package.json', cwd) ||
resolveModule('eslint/package.json', __dirname)
),
formatter: loadModule('eslint/lib/formatters/codeframe', cwd, true)
})
})
}
.add(/node_modules/)
.add(path.dirname(require.resolve('@vue/cli-service')))
.end()
.test(/\.(vue|(j|t)sx?)$/)
.use('eslint-loader')
.loader(require.resolve('eslint-loader'))
.options({
extensions,
cache: true,
cacheIdentifier,
emitWarning: allWarnings,
// only emit errors in production mode.
emitError: allErrors,
eslintPath: path.dirname(
resolveModule('eslint/package.json', cwd) ||
resolveModule('eslint/package.json', __dirname)
),
formatter: loadModule('eslint/lib/formatters/codeframe', cwd, true)
})
})
}
return progress.wrap(PROGRESS_ID, context, async setProgress => {
setProgress({
status: 'plugin-invoke',
args: [id]
})
clearModule('@vue/cli-service/webpack.config.js', cwd.get())
currentPluginId = id
// Allow plugins that don't have a generator
if (resolveModule(`${id}/generator`, cwd.get())) {
const child = execa('vue', [
'invoke',
id,
'--$inlineOptions',
JSON.stringify(prompts.getAnswers())
], {
cwd: cwd.get(),
stdio: ['inherit', 'pipe', 'inherit']
})
const onData = buffer => {
const text = buffer.toString().trim()
if (text) {
setProgress({
info: text
})
rules: [
// eslint
{
enforce: 'pre',
test: /\.js$/,
include: config.appSrc,
use: [
{
loader: require.resolve('eslint-loader'),
options: {
// TODO: cache 需要 cacheIdentifier,参考 vue-cli
// cache: true,
emitWarning: true,
emitError: false,
eslintPath: path.dirname(
resolveModule('eslint/package.json', context) ||
resolveModule('eslint/package.json', __dirname)
),
},
},
],
},
// js
{
test: /\.js$/,
exclude: (filepath) => {
// Notice: 处理 @babel/runtime 会导致很多没必要的 Polyfills,暂时去掉
// only include @babel/runtime when the babel-preset-autofe-app preset is used
// if (
// process.env.CREATOR_TRANSPILE_BABEL_RUNTIME &&
// filepath.includes(path.join('@babel', 'runtime'))
// ) {
// @bar/foo => @bar/vue-cli-plugin-foo
// @vue/foo => @vue/cli-plugin-foo
// foo => vue-cli-plugin-foo
const packageName = resolvePluginId(pluginName)
log()
log(`📦 Installing ${chalk.cyan(packageName)}...`)
log()
const packageManager = loadOptions().packageManager || (hasProjectYarn(context) ? 'yarn' : 'npm')
await installPackage(context, packageManager, options.registry, packageName)
log(`${chalk.green('✔')} Successfully installed plugin: ${chalk.cyan(packageName)}`)
log()
const generatorPath = resolveModule(`${packageName}/generator`, context)
if (generatorPath) {
invoke(pluginName, options, context)
} else {
log(`Plugin ${packageName} does not have a generator to invoke`)
}
}
// eslint
{
enforce: 'pre',
test: /\.js$/,
include: config.appSrc,
use: [
{
loader: require.resolve('eslint-loader'),
options: {
// TODO: cache 需要 cacheIdentifier,参考 vue-cli
// cache: true,
emitWarning: true,
emitError: false,
eslintPath: path.dirname(
resolveModule('eslint/package.json', context) ||
resolveModule('eslint/package.json', __dirname)
),
},
},
],
},
// js
{
test: /\.js$/,
exclude: (filepath) => {
// Notice: 处理 @babel/runtime 会导致很多没必要的 Polyfills,暂时去掉
// only include @babel/runtime when the babel-preset-autofe-app preset is used
// if (
// process.env.CREATOR_TRANSPILE_BABEL_RUNTIME &&
// filepath.includes(path.join('@babel', 'runtime'))
// ) {
// return false;
return progress.wrap(PROGRESS_ID, context, async setProgress => {
setProgress({
status: 'plugin-invoke',
args: [id]
})
clearModule('@vue/cli-service/webpack.config.js', cwd.get())
currentPluginId = id
// Allow plugins that don't have a generator
if (resolveModule(`${id}/generator`, cwd.get())) {
await invoke(id, prompts.getAnswers(), cwd.get())
}
// Run plugin api
runPluginApi(id, getApi(cwd.get()), context)
installationStep = 'diff'
notify({
title: `Plugin invoked successfully`,
message: `Plugin ${id} invoked successfully`,
icon: 'done'
})
return getInstallation(context)
})
}
log(`📦 Installing ${chalk.cyan(packageName)}...`)
log()
const pm = new PackageManager({ context })
const cliVersion = require('../package.json').version
if (isOfficialPlugin(packageName) && semver.prerelease(cliVersion)) {
await pm.add(`${packageName}@^${cliVersion}`)
} else {
await pm.add(packageName)
}
log(`${chalk.green('✔')} Successfully installed plugin: ${chalk.cyan(packageName)}`)
log()
const generatorPath = resolveModule(`${packageName}/generator`, context)
if (generatorPath) {
invoke(pluginName, options, context)
} else {
log(`Plugin ${packageName} does not have a generator to invoke`)
}
}