首页 > 网站 > WEB开发 > 正文

webpack之旅01-概述

2024-04-27 15:05:51
字体:
来源:转载
供稿:网友

WebPack是一个现代javaScript应用程序模块打包工具。它有四个核心概念: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: //.(js|jsx)$/, use: 'babel-loader'} ] }, plugins: [ new webpack.optimize.Uglifyjsplugin(), new HtmlWebpackPlugin({template: './src/index.html'}) ]};module.exports = config;There are many plugins that webpack

内建的plugins

第三方plugins


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表