Webpack & ESLint

为了能够在构建过程中就能发现ESlint的错误,这里我们可以使用插件eslint-webpack-pluginESLintWebpack进行绑定。

npm i -D eslint-webpack-plugin

再在webpack/webpack.base.js进行配置即可。

// webpack.base.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ESLintWebpackPlugin = require('eslint-webpack-plugin');

module.exports = {
  entry: {
    index: path.resolve(__dirname, '../src/index.js'),
  },
  output: {
    path: path.resolve(__dirname, '../dist'),
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, '../public/index.html'), 
      favicon: path.resolve(__dirname, '../public/logo.svg'), // 顺便加入favicon
    }),
    new ESLintWebpackPlugin({
      extensions: ['js','ts','vue']
    }),
  ]
}



 













 
 
 


SPONSORS 赞助商
Vue.js
渐进式JavaScript框架
your logo