entry和output
webpack.config.js | Configuration | webpack
- 创建
webpack.config.js文件 - 写入以下代码
代码含义:const path = require('path'); module.exports = { mode: 'development', entry: './foo.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'foo.bundle.js', }, };- 将当前目录下的
foo.js进行转译 - 新建一个
dist目录 - 转译之后的文件放在
dist目录 - 转译之后的文件名为
foobundle.js
- 将当前目录下的
示例
const path = require('path');
module.exports = {
mode: 'development',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.js',
},
};