Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
make eslint work for all modes
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Feb 15, 2017
1 parent 22e56a2 commit 369b8c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
4 changes: 3 additions & 1 deletion bin/vbuild-pack
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const cli = meow(`
${chalk.yellow('--watch, -w')} ${chalk.dim('Pack in watch mode')}
${chalk.yellow('--config, -c')} ${chalk.dim('Load config file')}
${chalk.yellow('--dist')} ${chalk.dim('Custom dist directory')}
${chalk.yellow('--eslint, -e')} ${chalk.dim('Add ESLint support')}
${chalk.yellow('--port, -p')} ${chalk.dim('Port of dev server')}
${chalk.yellow('--open, -o')} ${chalk.dim('Open browser')}
${chalk.yellow('--help, -h')} ${chalk.dim('Output help (You are here!)')}
Expand All @@ -30,7 +31,8 @@ const cli = meow(`
c: 'config',
o: 'open',
p: 'port',
w: 'watch'
w: 'watch',
e: 'eslint'
}
})

Expand Down
28 changes: 14 additions & 14 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ function start(cliOptions) { // eslint-disable-line complexity
}
}

if (options.eslint) {
webpackConfig.module.rules.push({
test: /\.(vue|js)$/,
loader: 'eslint-loader',
enforce: 'pre',
exclude: [/node_modules/],
options: Object.assign({
configFile: require.resolve('eslint-config-vue-app'),
useEslintrc: false,
fix: true
}, options.eslintConfig)
})
}

// copy ./static/** to dist folder
if (fs.existsSync('static')) {
webpackConfig.plugins.push(new CopyPlugin([{
Expand Down Expand Up @@ -215,20 +229,6 @@ function start(cliOptions) { // eslint-disable-line complexity

webpackConfig.devtool = 'source-map'

if (options.eslint) {
webpackConfig.module.rules.push({
test: /\.(vue|js)$/,
loader: 'eslint-loader',
enforce: 'pre',
exclude: [/node_modules/],
options: Object.assign({
configFile: require.resolve('eslint-config-vue-app'),
useEslintrc: false,
fix: true
}, options.eslintConfig)
})
}

webpackConfig.plugins.push(
new ProgressPlugin(),
new NoEmitOnErrorsPlugin(),
Expand Down

0 comments on commit 369b8c5

Please sign in to comment.