Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR in multi (webpack)-dev-server/client?http://localhost:8080 ./src when use webpack4.2.0

Tags:

webpack-4

when i use webpack4.2.0, play 'run start', show errors follow:

WARNING in configuration The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment.

ERROR in multi (webpack)-dev-server/client?http://localhost:8001 ./src Module not found: Error: Can't resolve './src' in '/Users/xudengwei/projects/xudengwei/myOpenGithub/angular5-scaffold' @ multi (webpack)-dev-server/client?http://localhost:8001 ./src ℹ 「wdm」: Failed to compile.

#

my configure as follow: webpack.common.js:

var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: {
        'polyfills': './src/polyfills.ts',
        'vendor': './src/vendor.ts',
        'app': './src/app/main.ts'
    },
    resolve: {
        extensions: ['.ts', '.js']
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                loader: "ts-loader"
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './index.html',
            inject: true
        })
    ]
};

webpack.dev.js:

var path = require('path');
var webpackMerge = require('webpack-merge');
var commonConfig = require('./webpack.common.js');

module.exports = webpackMerge(commonConfig, {
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name].js',
        chunkFilename: '[id].chunk.js'
    },
    module: {
        rules: []
    },
    plugins: [    
        new HtmlWebpackPlugin({
            template: './index.html',
            inject: true
        })
    ],
    devServer: {
        devServer: {
            contentBase: './dist'
        },
    }
});

someone knows the reason?thanks

like image 335
xudengwei Avatar asked Apr 01 '18 16:04

xudengwei


1 Answers

I also just get this error like you got and its was solved when i specify webpack config file. Try to add --config when you run webpack-dev-server. Ex. webpack-dev-server --config webpack.dev.js

like image 119
Adi Winata Avatar answered Sep 28 '22 08:09

Adi Winata