Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

How to use with eslint preloader? #15

Closed
iest opened this issue Sep 16, 2015 · 5 comments
Closed

How to use with eslint preloader? #15

iest opened this issue Sep 16, 2015 · 5 comments

Comments

@iest
Copy link

iest commented Sep 16, 2015

I'm not sure exactly where to put this and I apologise if this is the wrong repo — but I ran into an issue where if I used babel-eslint as a preloader (or before babel in the webpack loader config), hot reloading just would not work, and I always had this message:

[HMR] The following modules couldn't be hot updated: (Full reload needed)
[HMR]  - path/to/module
[HMR] Reloading page

No idea if this is a bug or what — just that I spent a long time trying to debug it!

Perhaps it will be of use to someone...

@edgesoft
Copy link

What does your webpack.config.js look like?

@iest
Copy link
Author

iest commented Sep 16, 2015

const path = require('path');
const webpack = require('webpack');
const assign = require('object-assign');

const config = require('./webpack.config');

module.exports = assign({}, config, {
  devtool: 'eval',
  entry: [
    'webpack-hot-middleware/client',
    './index',
  ],
  output: {
    filename: 'bundle.js',
    path: path.resolve('./public'),
    publicPath: '/public/',
  },
  module: {
    preLoaders: [
      {
        test: /\.js$/,
        loader: 'eslint',
        include: [__dirname, path.join(__dirname, '../components')],
        exclude: [path.join(__dirname, '../', 'node_modules')],
      },
    ],
    loaders: [
      {
        test: /\.(woff|woff2|gif|png|jpe?g)$/,
        loader: 'url-loader',
      }, {
        test: /\.svg$/,
        exclude: /icons\/.+\.svg$/, // exclude all icons inside /icons folder
        loader: 'url-loader!svgo-loader?useConfig=svgoConfig',
      }, {
        test: /icons\/.+\.svg$/,
        loader: 'raw-loader!svgo-loader?useConfig=svgoConfig',
      }, {
        test: /\.js$/,
        loaders: ['babel'],
        include: [path.join(__dirname, '../')],
        exclude: [path.join(__dirname, '../', 'node_modules')],
      }, {
        test: /\.css$/,
        loader: 'style-loader!css-loader?modules&importLoaders=1&localIdentName=[name]-[local]!postcss-loader',
      },
    ],
  },

  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('development'),
      },
    }),
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
  ],
});

Just dumping the preloaders makes it work.

@edgesoft
Copy link

Good to know. I guess you should create an issue here: https://github.com/glenjamin/webpack-hot-middleware/.

@gaearon
Copy link
Owner

gaearon commented Sep 16, 2015

Is this same as gaearon/babel-plugin-react-transform#12?

@iest
Copy link
Author

iest commented Sep 17, 2015

I can't really tell but it seems about right. Closing.

Also: thanks @gaearon !

@iest iest closed this as completed Sep 17, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants