npm start之后,打开http://localhost:8080/aa.html,以及http://localhost:8080/another.html控制台什么都没有输出,如果将package.json里的npm start改成webpack,去dist里找到aa.html,打开,控制台就会有输出。
目录结构
src
index.js
another-module.js
package.json
webpack.config.js
index.html
webpack配置文件
webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WebapckBundleAanlyzer = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
mode: "development",
entry: {
index: './src/index.js',
another: './src/another-module.js'
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
publicPath:'/',