简体   繁体   English

您可能需要适当的加载程序来处理此文件类型babel和webpack

[英]You may need an appropriate loader to handle this file type babel and webpack

So my file structure is pretty straight forward. 因此,我的文件结构非常简单。

~

/dist
/node_modules
/src
.babelrc
index.js
package.json
webpack.config.js

What I am trying to accomplish is I am trying to run this command "webpack" then have it build into my dist folder my compiled code. 我要完成的工作是尝试运行“ webpack”命令,然后将其编译到dist文件夹中。 I am then module.exporting it out to use it. 然后,我将module.export出来使用它。

However, I keep running into this error that says that I may need an appropriate loader for this file type. 但是,我一直遇到这个错误,该错误表明我可能需要这种文件类型的适当加载程序。 I feel as if I have all of my dev devependies that I need for it to compile. 我觉得好像我需要开发所有我的开发包一样。

Here are my following webpack.config.js as well as my package.json 这是我的以下webpack.config.js以及package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "webpack": "webpack"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-preset-stage-1": "^6.24.1",
    "lodash": "^4.17.4",
    "react": "^15.6.1",
    "react-dom": "^15.6.1"
  },
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "jsx-loader": "^0.13.2",
    "webpack": "^3.5.6",
    "webpack-dev-server": "^2.8.1"
  }
}


 module.exports = {
  entry: [
    './src/components/select.jsx'
  ],
  output: {
    path: __dirname + /dist/,
    publicPath: '/',
    filename: 'form-field.js'
  },
  module: {
    loaders: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loader: 'babel-loader',
      query: {
        presets: ['react', 'es2015', 'stage-1']
      }
    }]
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  devServer: {
    historyApiFallback: true,
    contentBase: './'
  }
};

You don't allow any file types in your loader. 您在加载程序中不允许使用任何文件类型。 Add a test key. 添加一个test密钥。

  loaders: [{
    test: /\.jsx?$/,
    exclude: /node_modules/,
    loader: 'babel',
    query: {
      presets: ['react', 'es2015', 'stage-1']
    }
  }]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Webpack和Babel的“您可能需要适当的加载器来处理此文件类型” - “You may need an appropriate loader to handle this file type” with Webpack and Babel Webpack 和 Babel “你可能需要一个合适的加载器来处理这种文件类型” - "You may need an appropriate loader to handle this file type" with Webpack and Babel 您可能需要适当的加载程序来处理此文件类型。 Webpack和Babel - You may need an appropriate loader to handle this file type. Webpack and Babel Webpack渲染sass,babel和es2015-您可能需要适当的加载程序来处理此文件类型 - Webpack rendering sass, babel and es2015 - You may need an appropriate loader to handle this file type 您可能需要适当的加载器才能通过babel / webpack2 / react处理此文件类型 - You may need an appropriate loader to handle this file type with babel/webpack2/react 您可能需要适当的加载程序来处理此文件类型。react.js,webpack,babel - You may need an appropriate loader to handle this file type.eith react.js,webpack,babel Webpack和babel配置问题:“您可能需要适当的加载程序来处理此文件类型。” - Webpack and babel configuration issue: “You may need an appropriate loader to handle this file type.” Babel Webpack错误:您可能需要适当的加载程序来处理此文件类型 - Babel Webpack Error: You may need an appropriate loader to handle this file type “你可能需要一个合适的加载器来处理这种文件类型”与 Webpack 和 CSS - “You may need an appropriate loader to handle this file type” with Webpack and CSS Webpack:您可能需要适当的加载器来处理此文件类型 - Webpack: You may need an appropriate loader to handle this file type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM