I am trying to use Webpack with Babel to compile ES6 assets, but I am getting the following error message:
You may need an appropriate loader to handle this file type. | import React from 'react'; | /* | import { render } from 'react-dom'
Here's what my Webpack configuration looks like:
var path = require('path'); var webpack = require('webpack'); module.exports = { entry: './index', output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/dist/' }, module: { loaders: [ { test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/ } ] } }
Here is the middleware step that Webpack uses:
var webpack = require('webpack'); var webpackDevMiddleware = require('webpack-dev-middleware'); var config = require('./webpack.config'); var express = require('express'); var app = express(); var port = 3000; var compiler = webpack(config); app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath })); app.get('/', function(req, res) { res.sendFile(__dirname + '/index.html'); }); app.listen(port, function(err) { console.log('Server started on http://localhost:%s', port); });
My entire index.js file does the import, reacting, but it looks like the "babel-loader" is not working.
I am using "babel-loader" 6.0.0.
javascript webpack babeljs es6-module-loader
egidra Nov 02 '15 at 2:40 2015-11-02 02:40
source share