issue with webpack-server 2

浪子不回头ぞ 提交于 2019-12-12 01:52:24

问题


When i run webpack server, it redirects me to folders of project not my index.html, but if I open it without webpack server it works fine, and nothing in network tab. I think my webpack.config.js not loaded correctely!

my webpack.confing.js :

    const ExtractTextPlugin = require("extract-text-webpack-plugin");
var path = require("path");


module.exports = {
    entry : './src/app.js',
    output : {
        path : path.resolve(__dirname,'dist'),
        filename : 'app.bundle.js'
    },
    module : {
        rules : [
            {test: /\.scss$/, 
            loader: ExtractTextPlugin.extract({
                fallback: "style-loader",
                use: ['css-loader','sass-loader'],
                publicPath: "/dist"
            })}
        ]
    },
    plugins: [
        new ExtractTextPlugin({
            filename: "app.scss",
            disable: false,
            allChunks: true
        })
    ]
}

回答1:


The problem is that you have misunderstood the public path concept that has nothing to do with file system path. That is, the publicPath is only related to the url.

url = `${host}:${port}${publicPath}${bundle}` 

Only change your extract text plugin parameter publicPath for '/'



来源:https://stackoverflow.com/questions/43955008/issue-with-webpack-server-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!