| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- const HtmlWebpackPlugin = require('html-webpack-plugin');
- const path = require('path');
- const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
- module.exports = {
- entry: './src/index.js',
- plugins: [
- new HtmlWebpackPlugin(
- {
- template: 'home.html'
- }
- ),
- new BundleAnalyzerPlugin({
- analyzerMode: 'static', // 也可以设置为 'server' 或 'disabled'
- openAnalyzer: true, // 打开浏览器显示结果
- })
-
- ],
- output: {
- filename: '[name].bundle.js',
- path: path.resolve(__dirname, 'dist'),
- },
- module: {
- rules: [
- {
- test: /\.css$/,
- use: ['style-loader', 'css-loader'],
- },
- {
- test: /path\.txt/,
- use: ['file-loader'],
- },
- {
- test: /\.(js|jsx)$/,
- exclude: /node_modules/,
- use: {
- loader: 'babel-loader'
- }
- },
- {
- test: /\.(png|jp(e*)g|svg|gif)$/,
- use: [
- {
- loader: 'file-loader',
- options: {
- name: 'images/[hash]-[name].[ext]',
- },
- },
- ],
- },
- ],
- },
- resolve: {
- extensions: [".js", ".jsx"]
- },
- mode: 'production',
- performance: {
- hints: false,
- maxEntrypointSize: 512000,
- maxAssetSize: 512000
- },
- devServer:{
- compress: false,
- port: 9002,
- static: './dist',
- client:{overlay: false}
- },
- };
|