2016-11-09 93 views
2

錯誤的文本爲什麼webpack返回錯誤ReferenceError:文檔沒有定義?

ERROR in ./static/main.sass 
    Module build failed: ModuleBuildError: Module build failed:ReferenceError: document is not defined 

ERROR in ./~/css-loader!./~/resolve-url/resolve-url.js!./~/sass-loader?sourceMap!./static/main.sass 
Module build failed: ReferenceError: document is not defined 
    at Object.resolveUrl (/home/andrew/Test/node_modules/resolve-url/resolve-url.js:21:25) 

的webpack.config.js

webpack = require('webpack'); 
    path = require('path'); 
    var ExtractTextPlugin = require('extract-text-webpack-plugin'); 
    webpackConfig = { 
context: __dirname, 
entry: { 
    bundle: './static/app.js', 
    styles: './static/main.sass' 
}, 
output: { 
    filename: '[name].js', 
    path: './static/build' 
}, 
resolve: { 
    extensions: ['', '.js', '.jsx'] 
}, 
devtool: '#cheap-module-source-map', 
module: { 
    loaders: [ 
     { 
      test: /\.jsx?$/, 
      exclude: [/node_modules/], 
      loader: "babel-loader", 
      query: { 
       presets: ['es2015', 'react', 'stage-0', 'stage-1'] 
      } 
     }, 
     { 
      test: /\.sass$/, 
      loader: ExtractTextPlugin.extract('css-loader!resolve-url!sass-loader?sourceMap') 
     }, 
     { 
      test: /\.css$/, 
      loader: ExtractTextPlugin.extract('style-loader', 'css-loader') 
     }, 
     { 
      test: /\.woff2?$|\.ttf$|\.eot$|\.svg$|\.png|\.jpe?g|\.gif$/, 
      loader: 'file-loader' 
     } 
    ] 
}, 
plugins: [ 
    new ExtractTextPlugin('styles.css', { 
     allChunks: true 
    }) 
]}; 
    module.exports = webpackConfig; 

我想這可能是沒有一些裝載機但這不是它。 除了app.js也不能在bundle.js中編譯,但它不會給出錯誤。也許進入時有一些錯誤,但我不知道。

回答

0

您需要在您的app.js(無論是requireimport)的SCSS文件,只有通過你的app.js文件條目的WebPack強似2檔作爲入門的。

相關問題