2017-09-19 26 views
1

我使用的是基於AngularJS 1.6(Typescript)的應用程序的webpack 2.4.2。 當我修改我的.ts,.js,.less等文件時,webpack自動檢查lint錯誤並報告它們。鉤在webpack編譯

我不知道webpack如何自動檢測更改並運行lint,但是,我想運行自定義命令,如檢查tslint錯誤。任何指示如何可以實現?

+0

推測它是在'loaders'或'rules'下的Webpack配置文件中。 –

回答

1

使用最新的webpack,這裏是你如何配置eslint。然而,你需要找到一個tslint加載器。

module.exports = { 
    module: { 
    rules: [ 
     { 
     test: /\.jsx?$/, 
     enforce: 'pre', 
     exclude: /(node_modules|bower_components)/, 
     use: 'eslint-loader' 
     } 
    ] 
    } 
} 
+0

這是如何回答這個問題的? – smnbbrv

+0

我收到以下錯誤 'multi(webpack)-dev-server/client?中的錯誤?http://0.0.0.0:8080 webpack/hot/dev-server ./src/index.ts 未找到模塊:錯誤:無法解析'/ home/cbdev1/cb/bas/client'中的'eslint-loader' @ multi(webpack)-dev-server/client?http://0.0.0.0:8080 webpack/hot/dev -server ./src/index.ts ' 根據最近對https://github.com/webpack/webpack/issues/1083 的評論'resolve:{ modules:[ path.join(__ dirname,「src 「), 」node_modules「 ] }' 但是,我已經在我的配置 – Phalgun

+0

我假設eslint-loader是在你的package.json? – danday74