小编Pet*_*rov的帖子

生产构建中未定义require(react.production.min.js)

美好的一天!我在生产上有一些麻烦:需求没有定义.它由react.production.min.js引起.这是我的webpack.config.js && package.json

webpack.config.js

const path = require('path');
const webpack = require('webpack');
const debug = process.env.NODE_ENV !== 'production';

let plugins = [
  new webpack.NoEmitOnErrorsPlugin(),
  new webpack.ProvidePlugin({
    Promise: 'imports-loader?this=>global!exports-loader?global.Promise!core-js/es6/promise',
    fetch: 'imports-loader?this=>global!exports-loader?global.fetch!fetch-polyfill'
  }),
  new webpack.DefinePlugin({
    'process.env':{
      'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
      'BASE_URL':JSON.stringify(process.env.BASE_URL)
    }
  })
];

if(!debug) {
  plugins.push(new webpack.optimize.UglifyJsPlugin({
    compress: {
      unsafe_comps: true,
      properties: true,
      keep_fargs: false,
      pure_getters: true,
      collapse_vars: true,
      unsafe: true,
      warnings: false,
      screw_ie8: true,
      sequences: true,
      dead_code: true,
      drop_debugger: true,
      comparisons: true,
      conditionals: true,
      evaluate: true,
      booleans: true,
      loops: true,
      unused: true, …
Run Code Online (Sandbox Code Playgroud)

javascript production node.js reactjs webpack

3
推荐指数
1
解决办法
784
查看次数

标签 统计

javascript ×1

node.js ×1

production ×1

reactjs ×1

webpack ×1