配置
// webpack.common.js
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const srcPath = path.join(__dirname, '..', 'src')
const distPath = path.join(__dirname, '..', 'dist')
module.exports = {
// ...
module: {
rules: [
// babel-loader
{
test: /\.js$/,
use: ['babel-loader?cacheDirectory'], // 已经编译过的不再编译, 只编译未编译的部分
include: srcPath,
exclude: /node_modules/
},
]
},
// ...
}