Webpack是一个针对JavaScript应用的打包工具,它按以下步骤来执行打包过程:
- 第归的扫描你的应用
- 根据扫描为你的应用构造一个包括所有模块的依赖关系图
- 根据关系图打包所有模块到一个或多个捆绑保(bundles)
Webpack包括4个核心概念
- 入口(Entry)
- 输出(Output)
- 装载(Loaders)
- 插件(Plugins)
请参看下面例子:
const HtmlWebpackPlugin = require(‘html-webpack-plugin‘); //installed via npmconst webpack = require(‘webpack‘); //to access built-in pluginsconst 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: /\.txt$/, use: ‘raw-loader‘ } ???] ?}, ?plugins: [ ???new webpack.optimize.UglifyJsPlugin(), ???new HtmlWebpackPlugin({template: ‘./src/index.html‘}) ?]};module.exports = config;
Webpack
原文地址:http://www.cnblogs.com/jinzd/p/7770628.html