admin管理员组文章数量:1430315
I cannot seem to get webpack-dev-server for webpack2 to work.
I am using the versions:
[email protected]
& [email protected]
Im getting the following CLI log:
http://localhost:8080/
webpack result is served from /
content is served from /var/www/homelyfe/hl-app/app/index.js
Hash: 2830dae8362c968c034c
Version: webpack 2.1.0-beta.25
Time: 544ms
Asset Size Chunks Chunk Names
run.build.js 47.6 kB 0 [emitted] app
index.html 198 bytes [emitted]
chunk {0} run.build.js (app) 43.4 kB [entry] [rendered]
[0] ./app/index.js 69 bytes {0} [built]
[1] (webpack)-dev-server/client?http://localhost:8080 4.14 kB {0} [built]
[2] ./~/punycode/punycode.js 14.7 kB {0} [built]
[3] ./~/querystring-es3/index.js 127 bytes {0} [built]
[4] ./~/url/url.js 23.3 kB {0} [built]
[5] (webpack)/buildin/global.js 506 bytes {0} [built]
[6] (webpack)/buildin/module.js 548 bytes {0} [built]
[7] multi app 40 bytes {0} [built]
ERROR in (webpack)-dev-server/client?http://localhost:8080
Module not found: Error: Can't resolve './socket' in '/var/www/homelyfe/hl-app/node_modules/webpack-dev-server/client'
@ (webpack)-dev-server/client?http://localhost:8080 4:13-32
@ multi app
ERROR in (webpack)-dev-server/client?http://localhost:8080
Module not found: Error: Can't resolve 'strip-ansi' in '/var/www/homelyfe/hl-app/node_modules/webpack-dev-server/client'
@ (webpack)-dev-server/client?http://localhost:8080 3:16-37
@ multi app
ERROR in (webpack)-dev-server/client?http://localhost:8080
Module not found: Error: Can't resolve 'webpack/hot/emitter' in '/var/www/homelyfe/hl-app/node_modules/webpack-dev-server/client'
@ (webpack)-dev-server/client?http://localhost:8080 124:19-49
@ multi app
ERROR in ./~/url/url.js
Module not found: Error: Can't resolve './util' in '/var/www/homelyfe/hl-app/node_modules/url'
@ ./~/url/url.js 25:11-28
@ (webpack)-dev-server/client?http://localhost:8080
@ multi app
ERROR in ./~/querystring-es3/index.js
Module not found: Error: Can't resolve './decode' in '/var/www/homelyfe/hl-app/node_modules/querystring-es3'
@ ./~/querystring-es3/index.js 3:33-52
@ ./~/url/url.js
@ (webpack)-dev-server/client?http://localhost:8080
@ multi app
ERROR in ./~/querystring-es3/index.js
Module not found: Error: Can't resolve './encode' in '/var/www/homelyfe/hl-app/node_modules/querystring-es3'
@ ./~/querystring-es3/index.js 4:37-56
@ ./~/url/url.js
@ (webpack)-dev-server/client?http://localhost:8080
@ multi app
Child html-webpack-plugin for "index.html":
chunk {0} index.html 539 kB [entry] [rendered]
[0] ./~/lodash/lodash.js 537 kB {0} [built]
[1] (webpack)/buildin/global.js 506 bytes {0} [built]
[2] (webpack)/buildin/module.js 548 bytes {0} [built]
[3] ./~/html-webpack-plugin/lib/loader.js!./~/html-webpack-plugin/default_index.ejs 540 bytes {0} [built]
webpack: bundle is now VALID.
My webpack.config.js
file looks like this:
const path = require( "path" );
const merge = require( "merge" );
const htmlWebpackPlugin = require( "html-webpack-plugin" );
const parts = require( "./webpack.config.parts" );
const PATHS = {
app : path.join( __dirname, "app" ),
build : path.join( __dirname, "build" )
};
const mon = {
entry : {
app : PATHS.app + "/index.js"
},
output : {
filename : "run.build.js",
path : PATHS.build
},
resolve : {
alias : {
ponents : path.resolve( __dirname, "app/ponents" )
},
extensions : [ "js", "jsx" ]
},
devServer : {
contentBase : PATHS.app
},
module : {
rules : [
{
test : "/\.jsx?$/",
use : [
{
loader : "babel-loader",
options : {
presets : [
"react",
"es2015"
]
}
}
]
}
]
},
plugins : [
new htmlWebpackPlugin({
title : "!!! testing webpack2 !!!"
})
]
};
var config;
switch( process.env.npm_lifecycle_event ){
case( "buildProd" ):
config = merge( mon,
{} );
case( "startDev" ):
default:
config = merge( mon,
{
devServer : {
contentBase : PATHS.app
}
});
}
module.exports = config;
What am I missing?
I cannot seem to get webpack-dev-server for webpack2 to work.
I am using the versions:
[email protected]
& [email protected]
Im getting the following CLI log:
http://localhost:8080/
webpack result is served from /
content is served from /var/www/homelyfe/hl-app/app/index.js
Hash: 2830dae8362c968c034c
Version: webpack 2.1.0-beta.25
Time: 544ms
Asset Size Chunks Chunk Names
run.build.js 47.6 kB 0 [emitted] app
index.html 198 bytes [emitted]
chunk {0} run.build.js (app) 43.4 kB [entry] [rendered]
[0] ./app/index.js 69 bytes {0} [built]
[1] (webpack)-dev-server/client?http://localhost:8080 4.14 kB {0} [built]
[2] ./~/punycode/punycode.js 14.7 kB {0} [built]
[3] ./~/querystring-es3/index.js 127 bytes {0} [built]
[4] ./~/url/url.js 23.3 kB {0} [built]
[5] (webpack)/buildin/global.js 506 bytes {0} [built]
[6] (webpack)/buildin/module.js 548 bytes {0} [built]
[7] multi app 40 bytes {0} [built]
ERROR in (webpack)-dev-server/client?http://localhost:8080
Module not found: Error: Can't resolve './socket' in '/var/www/homelyfe/hl-app/node_modules/webpack-dev-server/client'
@ (webpack)-dev-server/client?http://localhost:8080 4:13-32
@ multi app
ERROR in (webpack)-dev-server/client?http://localhost:8080
Module not found: Error: Can't resolve 'strip-ansi' in '/var/www/homelyfe/hl-app/node_modules/webpack-dev-server/client'
@ (webpack)-dev-server/client?http://localhost:8080 3:16-37
@ multi app
ERROR in (webpack)-dev-server/client?http://localhost:8080
Module not found: Error: Can't resolve 'webpack/hot/emitter' in '/var/www/homelyfe/hl-app/node_modules/webpack-dev-server/client'
@ (webpack)-dev-server/client?http://localhost:8080 124:19-49
@ multi app
ERROR in ./~/url/url.js
Module not found: Error: Can't resolve './util' in '/var/www/homelyfe/hl-app/node_modules/url'
@ ./~/url/url.js 25:11-28
@ (webpack)-dev-server/client?http://localhost:8080
@ multi app
ERROR in ./~/querystring-es3/index.js
Module not found: Error: Can't resolve './decode' in '/var/www/homelyfe/hl-app/node_modules/querystring-es3'
@ ./~/querystring-es3/index.js 3:33-52
@ ./~/url/url.js
@ (webpack)-dev-server/client?http://localhost:8080
@ multi app
ERROR in ./~/querystring-es3/index.js
Module not found: Error: Can't resolve './encode' in '/var/www/homelyfe/hl-app/node_modules/querystring-es3'
@ ./~/querystring-es3/index.js 4:37-56
@ ./~/url/url.js
@ (webpack)-dev-server/client?http://localhost:8080
@ multi app
Child html-webpack-plugin for "index.html":
chunk {0} index.html 539 kB [entry] [rendered]
[0] ./~/lodash/lodash.js 537 kB {0} [built]
[1] (webpack)/buildin/global.js 506 bytes {0} [built]
[2] (webpack)/buildin/module.js 548 bytes {0} [built]
[3] ./~/html-webpack-plugin/lib/loader.js!./~/html-webpack-plugin/default_index.ejs 540 bytes {0} [built]
webpack: bundle is now VALID.
My webpack.config.js
file looks like this:
const path = require( "path" );
const merge = require( "merge" );
const htmlWebpackPlugin = require( "html-webpack-plugin" );
const parts = require( "./webpack.config.parts" );
const PATHS = {
app : path.join( __dirname, "app" ),
build : path.join( __dirname, "build" )
};
const mon = {
entry : {
app : PATHS.app + "/index.js"
},
output : {
filename : "run.build.js",
path : PATHS.build
},
resolve : {
alias : {
ponents : path.resolve( __dirname, "app/ponents" )
},
extensions : [ "js", "jsx" ]
},
devServer : {
contentBase : PATHS.app
},
module : {
rules : [
{
test : "/\.jsx?$/",
use : [
{
loader : "babel-loader",
options : {
presets : [
"react",
"es2015"
]
}
}
]
}
]
},
plugins : [
new htmlWebpackPlugin({
title : "!!! testing webpack2 !!!"
})
]
};
var config;
switch( process.env.npm_lifecycle_event ){
case( "buildProd" ):
config = merge( mon,
{} );
case( "startDev" ):
default:
config = merge( mon,
{
devServer : {
contentBase : PATHS.app
}
});
}
module.exports = config;
What am I missing?
Share Improve this question edited Nov 11, 2016 at 10:06 Kayote asked Nov 10, 2016 at 16:41 KayoteKayote 15.7k26 gold badges96 silver badges152 bronze badges2 Answers
Reset to default 6The solution was to pass the --no-inline
option to the script in package.json
. So, within the package.json
, the scripts
obj would be:
"scripts" : {
"startDev" : "webpack-dev-server --no-inline"
}
https://webpack.js/configuration/dev-server/#devserver-inline-cli-only
The real problem is your extensions
key inside resolve
(webpack config) is set up wrong.
WRONG
extensions : [ "js", "jsx" ]
CORRECT
extensions : [ ".js", ".jsx" ]
Check https://github./webpack/webpack-dev-server/issues/720 or https://webpack.js/configuration/resolve/
I am using a different setup but got the same errors (nearly).
I think the --no-inline
is just a workaround.
本文标签: javascriptGet WebpackDevServer Running in Webpack2Stack Overflow
版权声明:本文标题:javascript - Get Webpack-Dev-Server Running in Webpack2 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745542087a2662538.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论