一起学Webpack 发表于 2018-04-15 Webpack 入门 不需要用script标签引入库, 一切依赖都可以通过npm安装。 插件系统很强大。 主要webpack.config.js文件 123456789101112131415161718192021222324252627282930313233343536373839const path = require('path');const webpack = require('webpack');const HtmlWebpackPlugin = require('html-webpack-plugin');const config = { entry: './index.js', //入口 output: { //输出 filename: 'bundle.js', path: path.resolve(__dirname, 'dist') }, module: { //正则方式匹配文件,对文件使用指定的module处理 rules: [{ test: /\.txt$/, use: 'raw-loader' }, { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/, options: { "presets": ["env"] } } ] }, plugins: [ //所使用的插件 new HtmlWebpackPlugin({ template: './index.html' }), new webpack.HotModuleReplacementPlugin() ], devServer: { hot: true, // 告诉devserver启用htm contentBase: path.resolve(__dirname, 'dist'), publicPath: '/' }}module.exports = config; 其他的用到了再查咯。