webpack.validateSchema不是survjs中的函数错误

时间:2018-03-02 14:58:41

标签: javascript webpack survivejs

我在设置webpack时遇到此问题webpack.validateSchema is not a function并在下面做出反应我共享了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, {});
}

1 个答案:

答案 0 :(得分:1)

要解决几个错误:

  • 使用extension: ['','.js','.jsx']而不是extensions: ['.js','.jsx']。自webpack 2以来就没有必要使用空条目,它会抱怨它。
  • 使用['style','css']而不是['style-loader','css-loader']。从webpack 2开始,默认情况下它不提供快捷方式。
  • 使用babel?cacheDirectory而不是babel-loader?cacheDirectory。我可以通过useoptions重写定义,如同the webpack book chapter