webpack hangs at on “95% emit” / “95% emitting”

爱⌒轻易说出口 提交于 2019-12-03 17:24:40

问题


This is my production webpack config. The two quotes in the title refer to webpack2 and webpack respectively. Both hang for me with a similar error.

This is my command to trigger the build

set NODE_ENV=production && webpack --config config/webpack.config.prod.js --progress --display-error-details

What am I missing?

Here is the output after running npm run pack which correlates to my production webpack build:

$ npm run pack

> somedir@ pack C:\somedir
> set NODE_ENV=production && webpack --config config/webpack.config.prod.js --progress --display-error-details
                           95% emitting

回答1:


So I figured this out. It turns out I was including reserved characters in my output path. I've since opened an issue on github.

When using an invalid or reserved character in the output.path webpack will hang with no output. Running with the --progress flag will show that it's hanging on 95% emit(ting) (suffix depending on webpack version).




回答2:


In my case (Windows environment and laravel-mix) there weren't any incorrect characters in the path, since even a dead simple configuration didn't work. It was just webpack (webpack@3.12.0) doing something stupid of his own and the problem has been solved using publicPath option like this:

mix.options({
    publicPath: ('./')
});

which according to the documentation:

allows you to specify the base path for all the assets within your application

Alternatively you can use:

mix.setPublicPath('./');



回答3:


I use laravel-mix as a standalone. This is my my config:

let mix = require('laravel-mix');

mix.setPublicPath('./')
   .js('resources/js/app.js', 'js')
   .sass('resources/sass/app.scss', 'css');

This worked for me.




回答4:


In my case I was trying to use Angular 4, Webpack 3, AOT and lazy loading.
Using @ngtools/webpack and AotPlugin made it freeze at 95%.

What fixed was:
1). Install node-sass with npm install node-sass --no-bin-links, because it was not installed automatically with sass-loader.
2). Adding these loaders for the SCSS/CSS files (even inside node modules):

        {
            test: /\.css$/,
            use: [
                'style-loader',
                'css-loader'
            ]
        },
        {
            test: /\.scss$/,
            use: [
                'raw-loader',
                'sass-loader'
            ]
        }



回答5:


npm rebuild node-sass

solved ist by me.




回答6:


This error also occurs if you have invalid import. Import referring from other files which is not getting compiled.




回答7:


I fixed by upgrading to webpack@4.41.2



来源:https://stackoverflow.com/questions/39085686/webpack-hangs-at-on-95-emit-95-emitting

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