webpack 配置参考(dev)

我的 webpack 配置文件(React 项目),自己动手搭的,留作参考

const webpack = require('webpack')
const path = require('path')
const ManifistPlugin = require('webpack-manifest-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')

const modules = require('./config/base')

const config = {
  entry: [
    'babel-polyfill',
    'react-hot-loader/patch',
    'webpack-dev-server/client?http://localhost:9000',
    path.join(__dirname, '/src/container/render')
  ],
  output: {
    publicPath: 'http://localhost:9000/',
    path: path.join(__dirname, '/dist'),
    filename: '[name].[hash:5].js'
  },
  module: modules,
  resolve: {
    extensions: ['.js', '.jsx', '.json', '.css', '.scss', '.sass'],
    alias: {
      '@': path.join(__dirname, '/src/container')
    }
  },
  devServer: {
    publicPath: path.join(__dirname, '/dist'),
    contentBase: path.join(__dirname, '/dist'),
    historyApiFallback: true,
    port: 9000,
    hot: true,
    inline: true,
    stats: 'normal'
  },
  plugins: [
    new ManifistPlugin(),
    new ExtractTextPlugin('/style.css'),
    new HtmlWebpackPlugin({
      template: path.join(__dirname, '/index.html')
    }),
    new webpack.NamedModulesPlugin(),
    new webpack.HotModuleReplacementPlugin({}),
    new webpack.SourceMapDevToolPlugin({
      filename: '[name].[hash:5].map'
    })
  ]
}

module.exports = config
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容