我试图设置我的vuejs应用程序的html linting,但我不知道如何正确配置我的webpack配置。我目前正在尝试使用Html线索-加载程序。我使用以下命令安装了它:
npm install htmlhint-loader --save并在我的webpack.base.config中添加了以下代码
module: {
preLoaders: [
{
test: /\.vue$/,
loader: 'eslint', // I'm already using eslint which works as expected
include: projectRoot,
exclude: /node_modules/
},
{
test: /\(vue|html)$/,
loader: 'htmlhint',
include: projectRoot,
exclude: /node_modules/
},
...
...但这是行不通的,让我知道,如果还有什么是需要的,使其发挥作用。
当我使用这个正则表达式时:
test: /(vue|html)$/,我得到以下错误:
./~/html-webpack-plugin/lib/loader.js!./index.html模块解析中的错误:>/Users/saurabh.mimani/work/codes/j/vue/node_modules/html-webpack-plugin/lib/loader.js!/Users/saurabh.mimani/work/codes/j/vue/node_modules/htmlhint-loader/index.js!/Users/saurabh.mimani/work/codes/j/vue/index.html意外令牌(1:0)您可能需要一个适当的加载程序来处理此文件类型。(/Users/saurabh.mimani/work/codes/j/vue/node_modules/webpack/node_modules/acorn/dist/acorn.js:2221:15):(/Users/saurabh.mimani/work/codes/j/vue/node_modules/webpack/node_modules/acorn/dist/acorn.js:603:10) at Parser.pp$3.parseExprAtom (/ /Users/saurabh.mimani/work/codes/j/vue/node_modules/webpack/node_modules/acorn/dist/acorn.js:1822:12) at Parser.pp$3.3.parseExprSubscripts (/Users/saurabh.mimani/work/codes/j/vue/node_modules/webpack/node_modules/acorn/dist/acorn.js:1715:21)
发布于 2017-02-10 09:41:18
htmlhint-loader无法检查vue -> template代码。但是htmllint装载机可以工作得很好。
发布于 2017-08-31 23:31:28
你需要webpack-联合装载机
var combineLoaders = require('webpack-combine-loaders')
...
preLoaders: {
html: combineLoaders([
{
loader: 'htmlhint-loader',
exclude: /node_modules/,
options: {
rulesDir: 'rules/',
'my-new-rule': 'this is pass to the rule (option)'
}
}
])
}
...
https://stackoverflow.com/questions/41648310
复制相似问题