webpack: Webpack - No Output File, No Errors Reported
I am learning Webpack and going through it again and again. In the latest build, there is something very strange going on. CLI reports everything is well & the output file dress_aphrodite.js is emitted, yet its nowhere to be found in the folder.
Here are the logs: From CLI:
http://localhost:8080/webpack-dev-server/
webpack result is served from /app/
content is served from ./app
Hash: 5334867c12acfa65ba90
Version: webpack 1.12.9
Time: 1966ms
Asset Size Chunks Chunk Names
dress_aphrodite.js 390 kB 0 [emitted] main
dress_aphrodite.js.map 479 kB 0 [emitted] main
chunk {0} dress_aphrodite.js, dress_aphrodite.js.map (main) 354 kB [rendered]
[0] multi main 52 bytes {0} [built]
[1] ./~/babel-polyfill/lib/index.js 209 bytes {0} [built]
[2] ./~/core-js/shim.js 4.31 kB {0} [built]
[3] ./~/core-js/modules/es5.js 10.2 kB {0} [built]
...
[263] ./~/ansi-regex/index.js 135 bytes {0} [built]
webpack: bundle is now VALID.
So everything looks good above. Yet, there is no dress_aphrodite.js
file in the main folder or ./app
folder.
Here is the webpack.config.js file:
var path = require ('path');
var webpack = require ('webpack');
module.exports = {
entry : [
'babel-polyfill',
'./app/da',
'webpack-dev-server/client?http://localhost:8080'
],
resolve : {
extension : ['', '.js', '.jsx', '.json']
},
output : {
publicPath : '/app/',
filename : 'dress_aphrodite.js'
},
debug : true,
devtool : 'source-map',
devServer : {
contentBase : './app'
},
module: {
loaders: [
{
test : /\.js$/,
include : path.join (__dirname, 'app'),
loader : 'babel-loader',
query : {
presets : ["es2015"]
}
}
]
}
};
And finally, incase, anyone needs the package.json file, here it is:
{
"name": "dress_aphrodite",
"version": "1.0.0",
"description": "",
"main": "dress_aphrodite.js",
"scripts": {
"start": "node_modules/webpack-dev-server/bin/webpack-dev-server.js"
},
"author": "",
"license": "ISC"
}
Any help as to why the output file is not being emitted / rendered?
Thanks
Edit: Tried without the Output.publicPath
(as suggested by YuWu), still no change. Changed it to path
property & still no change as well.
Edit 2: As a test, I added the html-webpack-plugin
into the webpack.config.js
file to see if it would be emitted by webpack and yes, apparently that too has been emitted and yet I cannot see.
Edit 3: (Post generous conversation with YuWu) : The webpack-dev-server
is running fine and displaying the window.alert in the js file along with the dynamic html file created via html-webpack-plugin
. I recall installing the webpack-dev-server
globally. Could that be where the html & the js emitted files are being stored?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 22
- Comments: 30 (6 by maintainers)
Commits related to this issue
- Remove source-map to see if building works without it See: https://github.com/webpack/webpack/issues/1736 — committed to Codaisseur/code-practice-BAK by deleted user 8 years ago
Please note that webpack-dev-server runs in memory by design. If you want a real bundle, build through webpack.
I had the same problem but i could solve it by require this
const path = require('path')
and in my output object i add this linepath: path.resolve(__dirname, 'dist/assets')
Im not sure whether I should be embarrassed about this or not :!
devtool
command works fine and the source file is created.So sorry about this & thank you for the attention towards this @bebraw :!
I ran the webpack command as well. It doesnt seem to store the file in the directory.
Also, the output properties should be respected and the bundle output should have been stored in the directory, no?
You can supply the
writeToDisk
option to have the files written to disk instead of in memory.Thank you bebraw, that tip about the webpack-dev-server running in memory saved me from giving up and switching back to Gulp for my project.
Same issue, figured out that problem related to uglifyjs-webpack-plugin@2.0.1, rollback to uglifyjs-webpack-plugin@1.3.0 and it works again.
After combing through it line by line, the culprit seems to be this:
So, yes, the dev-server stores the emitted files in memory, however, why is the command not giving any error and making the files not appear in the folder?
Do I need to install anything additional for devtool?
You can use this plugin to force the webpack dev server to write files to the disk!
Encountered this behaviour again with one of the RiotJS examples: https://github.com/riot/examples/blob/gh-pages/webpack/webpack.config.js
changing
path: '/public'
topath: 'public/'
makes it build properly. Weird. I’m running under mingw on windows 10 btw:@Kay2dan I noticed that you don’t have an
output.path
. Try addingoutput : { path: 'app/', }
. NOTE not/app/
.I’m getting weird inconsistencies with webpack like you’ve described - i.e. no errors but no output and I’m not using
devtool : 'source-map'
. In my case it seems to work sometimes with output.path = /app/, and sometimes it doesn’t produce output. But with output.path = app/ it seems to be working more consistently. I’ve only just discovered this issue so am not clear whether this fix works permanently.NB there are some path relative issues:
$/src/webpack.app.config.js
webpack --display-modules --config src/webpack.app.config.js
You can find the code in my style-loader bug report:
path: '/build/'
which seems to work sometimes (once?). Try change it topath: 'build/'
for more consistent output.As an aside there’s a path inconsistency between
output.path
andrequire
- the former is relative to root whereas the later is relative to the file AFAIK i.e.Sometimes, webpack fails when configuration has mistakes when using
path
library.In my case, webpack run perfectly but produced no output.
My mistake was using an unnecessary slash in the
output.path
option.Just compare BAD: no output bundle file created**
GOOD: webpack produces the expected bundle file
If the target output path is a valid folder, then webpack generates a bundle file, otherwise, will not, reporting zero errors.
So @Kay2dan, have you check how you use
path
?@smac89 our hero!