Webpack配置
const path = require(‘path‘);
const Webpack = require(‘webpack‘);
const HtmlWebpackPlugin = require(‘html-webpack-plugin‘);
const ManifestPlugin = require(‘webpack-manifest-plugin‘);
const UglifyJsPlugin = require(‘uglifyjs-webpack-plugin‘);
module.exports = {
  entry: path.resolve(__dirname, ‘../src/index.jsx‘),
  output: {
    filename: "[name].bundle.js",
    path: path.resolve(__dirname, ‘dist‘),
    publicPath: process.env === ‘production‘ ? ‘dist‘ : ‘/‘
  },
  devtool: ‘inline-source-map‘,
  devServer: {
    contentBase: ‘./dist‘,
    hot: true,
    inline: true,
    open: true,
    overlay: true,
    host: ‘0.0.0.0‘,
    proxy: {}
  },
  resolve: {
    extensions: [‘.less‘, ‘.jsx‘, ‘.js‘],
    alias: {
      ‘@‘: ‘src‘,
      ‘components‘: ‘src/components‘,
      ‘container‘: ‘src/container‘,
      ‘view‘: ‘src/view‘,
      ‘common‘: ‘src/common‘,
      ‘base‘: ‘src/base‘
    }
  },
  module: {
    rules: [
      { test: ‘/\.css$/‘, use: [‘css-loader‘, ‘style-loader‘] },
      { test: ‘/\.jsx/‘, use: [‘babel-loader‘] },
      { test: ‘/\.(png|jpg|svg|gif|woff|woff2|eot|ttf|otf)$/‘, use: [‘file-loader‘] }
    ]
  },
  plugins: [
    new ManifestPlugin(),
    new HtmlWebpackPlugin({
      title: "Webpack App"
    }),
    new UglifyJsPlugin({
      sourceMap: true
    }),
    new Webpack.optimize.CommonsChunkPlugin({
      name: ‘manifest‘
    }),
    new Webpack.HotModuleReplacementPlugin(),
    new Webpack.DefinePlugin({
      ‘process.env.NODE_ENV‘: JSON.stringify(‘production‘)
    }),
  ]
}; 相关推荐
  不知道该写啥QAQ    2020-11-12  
   webfullStack    2020-11-09  
   Yvettre    2020-09-15  
   想做大牛的蜗牛    2020-10-30  
   gaojie0    2020-09-11  
   SelinaChan    2020-08-14  
   不知道该写啥QAQ    2020-08-09  
   gloria0    2020-08-09  
   不知道该写啥QAQ    2020-08-02  
   hline    2020-07-29  
   SelinaChan    2020-07-28  
   wangdianyong    2020-07-23  
   webpackvuees    2020-07-23  
   yqoxygen    2020-07-20  
   不知道该写啥QAQ    2020-07-18  
   waterv    2020-07-18