1.module中rules理解
const path = require('path');
const config = {
entry: './path/to/my/entry/file.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'my-first-webpack.bundle.js'
},
module: {
rules: [
{test: /\.(js|jsx)$/, use: 'babel-loader'}
]
}
};
module.exports = config;
在module中定義的rules中必須包含
test,use
這個(gè)規(guī)則的意思是在碰到 .js|.jsx的文件時(shí)需要先用babel-loader轉(zhuǎn)換一下
2.__dirname 和 path.resolve([..paths])
__dirname
path.resolve([..paths])
3.loader的三種使用方法
之前自己玩過(guò)cli方式的
loader的三種使用方法