簡體   English   中英

為什么webpack build上沒有定義'document'錯誤?

[英]Why is 'document' is not defined error on webpack build?

我正准備在Heroku上放一個小反應應用程序並正在進行生產配置。 當我運行npm run build all。 但是,當我運行構建的文件node dist/dist.js我收到錯誤:

ReferenceError: document is not defined

我應該使用不同的css加載器嗎? 我的webpack.deployment.config.js如下:

    const path = require('path');
const webpack = require('webpack');

module.exports = {
  devtool: 'source-map',

  entry: [
    './client/index.js'
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js',
    publicPath: './dist/'
  },
  plugins: [
    new webpack.optimize.UglifyJsPlugin({
      minimize: true,
      compress: {
        warnings: false
      },
      sourceMap: true
    })
  ],
  module: {
    loaders: [{
      test: /.jsx?$/,
      loader: 'babel-loader',
      include: path.join(__dirname, 'client'),
      exclude: /node_modules/,
      query: {
        presets: ['es2015', 'react']
      }
    },
     { test: /\.css$/, loader: "css-loader" },
     { test: /\.(jpg|png|svg)$/, use: 'file-loader'}

    ]
  },
};

npm模塊jsdom可用於在非瀏覽器環境中提供窗口和文檔。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM