Webpack 2:无法读取属性' Base64'未定义的

时间:2016-10-26 15:26:44

标签: javascript node.js webpack postcss webpack-2

我是Webpack的新手。我的React配置有效,但当我尝试import postcssJs from 'postcss-js'时,浏览器会在Uncaught TypeError: Cannot read property 'Base64' of undefined上的捆绑中抛出var _Base64 = global.Base64;

这是我的webpack配置:

module.exports = {
  entry: './demo/js/components/App.js',

  output: {
    path: __dirname + '/demo/js',
    filename: 'bundle.js'
  },

  module: {
    loaders: [
      {
        test: /\.(js|jsx)$/,
        loader: 'babel',
        query: {
          presets: [
            'es2015',
            'stage-0',
            'react'
          ],
          plugins: [
            'transform-react-stateless-component-name'
          ]
        }
      }
    ]
  },

  node: {
    fs: 'empty'
  },

  watch: true
}

以下是我遇到问题的React文件:

import React from 'react'

import postcssJs from 'postcss-js' // When I comment out this line, everything works fine.

export default ({greeting}) => <h3>{greeting}</h3>

我确定我只是缺少一些关于使用某种装载机或类似东西的基本Webpack范例,但我无法弄清楚。

我非常感谢任何帮助,因为这已经阻止了我好几个小时......

以下是我的依赖项:

"dependencies": {
  "chalk": "^1.1.3",
  "postcss": "^5.2.5",
  "postcss-value-parser": "^3.3.0"
},
"devDependencies": {
  "babel-cli": "^6.18.0",
  "babel-loader": "^6.2.5",
  "babel-plugin-add-module-exports": "^0.2.1",
  "babel-plugin-transform-flow-strip-types": "^6.18.0",
  "babel-plugin-transform-react-stateless-component-name": "^1.0.1",
  "babel-preset-es2015": "^6.18.0",
  "babel-preset-react": "^6.16.0",
  "babel-preset-stage-0": "^6.16.0",
  "browser-sync": "^2.17.5",
  "imports-loader": "^0.6.5",
  "lodash": "^4.16.4",
  "npm-run-all": "^3.1.1",
  "postcss-js": "^0.1.3",
  "react": "^15.4.0-rc.4",
  "react-dom": "^15.4.0-rc.4",
  "stylus": "^0.54.5",
  "webpack": "^2.1.0-beta.25"
}

它没有巴别塔,但我需要巴别......

0 个答案:

没有答案