webpack babel'要求未定义'

时间:2016-12-14 23:11:21

标签: javascript webpack babeljs

我在运行webpack-dev-server时遇到奇怪的浏览器警告,但没有来自webpack或webpack-dev-server的警告。 我已经找到了解决方案,但所有类似的过去问题都出现在2015年中期。

目前这种跟踪水平超出了我的范围。

错误如下:

  

未捕获的ReferenceError:未定义require       在对象。 (http://localhost:8080/public/js/main.js:38204:2)       在 webpack_require >(http://localhost:8080/public/js/main.js:20:30)       在对象。 (http://localhost:8080/public/js/main.js:38039:12)       在 webpack_require >(http://localhost:8080/public/js/main.js:20:30)       在对象。 (http://localhost:8080/public/js/main.js:20467:25)       在 webpack_require >(http://localhost:8080/public/js/main.js:20:30)       在对象。 (http://localhost:8080/public/js/main.js:55:13)       在 webpack_require >(http://localhost:8080/public/js/main.js:20:30)       在http://localhost:8080/public/js/main.js:40:18       在http://localhost:8080/public/js/main.js:43:10

38204:

require('./browser_loader');

webpack.config.js

module.exports = {
  entry: './src/index.js',
  output: {
    path: __dirname + '/public/js',
    filename: 'main.js'
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  module: {
    noParse: [/aws-sdk/],
    loaders: [{
      test: /\.jsx?$/,
      loader: 'babel-loader',
      exclude: /node_modules/,
      query: {
        presets: ['react', 'es2015']
      }
    }, 
    {
      test: /\.sass$/,
      loader: 'style!css!sass?indentedSyntax=true&sourceMap=true'
    }]
  },
}

index.js

import React from 'react';
import { render } from 'react-dom';
import App from './components/app';
//import '../css/main.css';
import '../css/main.sass';

render (<App />, document.getElementById('app'));

0 个答案:

没有答案