In short, I need to jshint tests specifications in parallel with the package sources during the build process.
Using the Webpack 3, how to make jshint-loader
to watch out for two different folders with two different .jshintrc
files? One pack of sources with .jshintrc
is in the ./src
folder, which is bundling to the end distributive, and the other one pack with another .jshintrc
is in the ./test
folder, which does not mentioned in the Webpack config (Karma handles it).
I tried the following two approaches, and both of them processed ./src
only, they didn't do anything with ./test
.
First version of Webpack config:
entry: {
'ui-scroll': path.resolve(__dirname, '../src/ui-scroll.js'),
'ui-scroll-grid': path.resolve(__dirname, '../src/ui-scroll-grid.js')
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: { presets: ['es2015'] }
},
{
enforce: 'pre',
test: /\.js$/,
include: path.resolve(__dirname, '../src'),
use: [{ loader: 'jshint-loader' }]
},
{
enforce: 'pre',
test: /\.js$/,
include: path.resolve(__dirname, '../test'),
use: [{ loader: 'jshint-loader' }]
}
]
},
// ...
The second version of Webpack config differs in the module-rules part:
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: { presets: ['es2015'] }
},
{
enforce: 'pre',
test: /\.js$/,
include: [
path.resolve(__dirname, '../src'),
path.resolve(__dirname, '../test')
],
use: [{ loader: 'jshint-loader' }]
}
]
},
// ...
But as I said this doesn't work. Full config/sources could be obtained from this repository. So is it possible to fix my approach or do I need try something quite different?