ravencrown / play-webpack

全面解析 webpack 核心功能和优化策略,源码分析

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

webpack 核心概念之 entry/output

ravencrown opened this issue · comments

entry用法

entry 是webpack的入口,支持单页面和多页面的形式

// 单页面, entry是一个字符串
module.exports = {
    entry: './path/to/my/entry/file.js'
};

// 多页面,entry 是一个对象
module.exports = { 
    entry: {
        app: './src/app.js',
        adminApp: './src/adminApp.js' 
    }
};

output用法

output 用来告诉webpack如何将编译后的文件输出到磁盘

// 单入口配置
module.exports = {
    entry: './path/to/my/entry/file.js',
    output: {
        filename: 'bundle.js’,
        path: __dirname + '/dist' 
    }
};

// 多入口配置
module.exports = { 
    entry: {
        app: './src/app.js',
        search: './src/search.js' 
    },
    output: {
        filename: '[name].js', path: __dirname + '/dist'
    } 
};