学习react基本语法初始化webpack.config.js

const path = require('path')
const htmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  entry: path.join(__dirname, './src/main.js'),
  output: {
    path: path.join(__dirname, './dist'),
    filename: 'bundle.js'
  },
  plugins: [ // 插件
    new htmlWebpackPlugin({
      template: path.join(__dirname, './src/index.html'),
      filename: 'index.html'
    })
  ],
  module: {
    rules: [
      { test: /.css$/, use: ['style-loader', 'css-loader?modules&localIdentName=[name]_[local]-[hash:5]'] }, // 通过 为 css-loader 添加 modules 参数,启用 CSS 的模块化
      { test: /.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
      { test: /.(png|gif|bmp|jpg)$/, use: 'url-loader?limit=5000' },
      { test: /.jsx?$/, use: 'babel-loader', exclude: /node_modules/ }
    ]
  }
}
原文地址:https://www.cnblogs.com/itcast-guoke/p/12920441.html