我正在尝试将webpack实现到我的ReactJS项目中。这是我的webpack.config.js文件:
module.exports = {
entry: "./src/js/main.js",
output: {
path: "./dist",
filename: "bundle.js",
publicPath: "/"
},
devServer: {
inline: true,
contentBase: "./dist"
},
module: {
preLoaders: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: "eslint-loader"
}
],
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: "babel",
query: {
presets: ["es2015", "react"]
}
}
]
},
eslint: {
plugins: ["react"],
parserOptions: {
ecmaVersion: 6,
sourceType: "module",
ecmaFeatures: {
"jsx": true
}
},
env: {
es6: true,
browser: true
},
rules: {
quotes: 0
}
}
};
现在,在保存时,我的浏览器重新加载,这是Webpack的一个很好的内置功能。但我也不能让它在保存时运行ESLint测试。
另外 - 我计划实现一些单元测试和少量到css编译,也可以在文件保存上进行。这就是为什么我决定看看这些事情是如何完成的,并尝试用ESLint进行这样的自动功能......但仍然没有成功。