1

i am getting this issue webpack.validateSchema is not a function when i setting up webpack and react below i shared my webpack.config.js

const path = require('path');
const merge = require('webpack-merge');
const webpack = require('webpack');
const TARGET = process.env.npm_lifecycle_event;
const PATHS = {
    app: path.join(__dirname, 'app'),
    build: path.join(__dirname, 'build')
};

const common = {
    entry: {
        app: PATHS.app
    },
    output: {
        path: PATHS.build,
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            {
                test: /\.css$/,
                loaders: ['style','css'],
                include: PATHS.app,
            }
        ]
    }
};

if(TARGET === 'start' || !TARGET){
    module.exports = merge(common, {
        devtool: 'eval-source-map',
        devServer: {
            contentBase: PATHS.build,
            historyApiFallback: true,
            hot: true,
            inline: true,
            progress: true,
            stats: 'errors-only',
            host: process.env.HOST,
            port: process.env.PORT || 3000
        },
        plugins: [
            new webpack.HotModuleReplacementPlugin()
        ]
    });
}
if(TARGET === 'build'){
    module.exports = merge(common, {});
}
satyajit rout
  • 1,623
  • 10
  • 20

1 Answers1

1

There are a couple of errors to fix:

  • Instead of extension: ['','.js','.jsx'], use extensions: ['.js','.jsx']. There's no need for the empty entry since webpack 2 and it will complain about it.
  • Instead of ['style','css'], use ['style-loader','css-loader']. Since webpack 2, it doesn't provide the shortcut by default.
  • Instead of babel?cacheDirectory, use babel-loader?cacheDirectory. I might rewrite the definition through use and options as in the webpack book chapter.
Juho Vepsäläinen
  • 26,573
  • 12
  • 79
  • 105