使用webpack压缩时出现WebDrivero问题
由于某些原因,当我尝试使用webpack进行压缩时,我的WebDrivero找不到/protocol和/command目录 它给了我这个错误:使用webpack压缩时出现WebDrivero问题,webpack,source-maps,webdriver-io,Webpack,Source Maps,Webdriver Io,由于某些原因,当我尝试使用webpack进行压缩时,我的WebDrivero找不到/protocol和/command目录 它给了我这个错误: Uncaught Error: ENOENT: no such file or directory, scandir '/protocol' at Object.fs.readdirSync (fs.js:871:18) at getImplementedCommands (chrome-extension://chldbooigfagk
Uncaught Error: ENOENT: no such file or directory, scandir '/protocol'
at Object.fs.readdirSync (fs.js:871:18)
at getImplementedCommands (chrome-extension://chldbooigfagkknimlieldoieoahlncn/vendor.npm.js:119349:39)
at Object.<anonymous> (chrome-extension://chldbooigfagkknimlieldoieoahlncn/vendor.npm.js:80520:66)
at __webpack_require__ (chrome-extension://chldbooigfagkknimlieldoieoahlncn/manifest.js:51:30)
at Object.618 (chrome-extension://chldbooigfagkknimlieldoieoahlncn/index.js:1445:20)
at __webpack_require__ (chrome-extension://chldbooigfagkknimlieldoieoahlncn/manifest.js:51:30)
at Object.617 (chrome-extension://chldbooigfagkknimlieldoieoahlncn/index.js:1409:16)
at __webpack_require__ (chrome-extension://chldbooigfagkknimlieldoieoahlncn/manifest.js:51:30)
at Object.616 (chrome-extension://chldbooigfagkknimlieldoieoahlncn/index.js:1329:14)
at __webpack_require__ (chrome-extension://chldbooigfagkknimlieldoieoahlncn/manifest.js:51:30)
Webpack有两个名为commands和protocol的目录,压缩时找不到它们
这是我的网页配置:
module.exports = {
// common options
// the grunt-webpack merges the "options" objects with each task config (nested)
options: {
stats: {
timings: true,
children: false
},
context: j( ".", "src" ),
output: {
// name each file by their entry module name
filename: "[name].js",
// don't use the webpack:// protocol in sourcemaps
devtoolModuleFilenameTemplate: "/[resource-path]"
},
// the entry module
entry: {
main: "main",
index: "index"
},
resolve: {
modulesDirectories: [
"web_modules",
"node_modules",
"bower_components"
],
alias: {
// folder aliases
"root" : pRoot,
"server" : pServer,
"styles" : pStyles,
"img" : pImages,
"templates" : pTemplates,
"bower" : pModulesBower,
// app folders
"addons" : r( pApp, "addons" ),
"authenticators" : r( pApp, "authenticators" ),
"authorizers" : r( pApp, "authorizers" ),
"config" : r( pApp, "config" ),
"initializers": r( pApp, "initializers" ),
"mixins" : r( pApp, "mixins" ),
"services" : r( pApp, "services" ),
"helpers" : r( pApp, "helpers" ),
"models" : r( pApp, "models" ),
"controllers" : r( pApp, "controllers" ),
"routes" : r( pApp, "routes" ),
"components" : r( pApp, "components" ),
"store" : r( pApp, "store" ),
"utils" : r( pApp, "utils" ),
"gui" : r( pApp, "gui" ),
"session-stores" : r( pApp, "session-stores" ),
"shim" : r( pRoot, "shim" ),
"config2" : r( pRoot, "config" ),
}
},
resolveLoader: {
root: pRoot,
modulesDirectories: [
"web_loaders",
"web_modules",
"node_loaders",
"node_modules"
]
},
plugins: [
// don't split the main module into multiple chunks
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
// split into chunks by module path
new SplitByPathPlugin([
{
name: "vendor.bower",
path: pModulesBower
},
{
name: "vendor.npm",
path: pModulesNpm
},
{
name: "templates",
path: pTemplates
}
]),
// don't include css stylesheets in the js bundle
cssExtractTextPlugin,
lessExtractTextPlugin,
// ignore l10n modules of momentjs
new webpack.IgnorePlugin( /^\.\/locale$/, /moment$/ )
]
},
// -----
// task configs
// -----
dev: {
output: {
path: "<%= dir.tmp_dev %>"
},
resolve: {
root: [pApp, pAppServer]
},
target: "node-webkit",
devtool: "source-map",
module: {
loaders: [].concat( [ loaderBabelDev, ], commonLoaders ),
rules: [
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre"
}
]
},
plugins: [
// NW.js package.json
new CopyWebpackPlugin([
{ from: r( pRoot, "package.json" ) },
{ from: r( pRoot, "drivers", "selenium-server-standalone-3.2.0.jar" ),
to: "drivers" },
{ from: r( pRoot, "drivers", "chromedriver_mac64" ), to: "drivers" },
{ from: r( pServer, "config"), to: "config"},
{ from: r( pServer, "data"), to: "data"},
]),
new WebpackShell({
//onBuildStart: ["npm run babel"],
onBuildExit:
[`chmod 0755 ${j(pBuildRoot, "drivers/chromedriver_mac64")}`],
}),
new HtmlWebpackPlugin({
inject: "head",
hash: false,
template: r( pRoot, "index.html" )
}),
new webpack.DefinePlugin({
DEBUG: true,
"process.env":{
"NODE_ENV": JSON.stringify("production")
}
}),
new NwjsPlugin({
files: "<%= dir.tmp_dev %>/**",
argv: "--remote-debugging-port=8888",
rerunOnExit: true,
log: true,
logStdOut: false,
logStdErr: true
}),
],
watch: true,
keepalive: true,
failOnError: false
},
prod: {
output: {
path: "<%= dir.tmp_prod %>"
},
resolve: {
root: pApp
},
target: "node-webkit",
module: {
loaders: [].concat( [ loaderBabelProd, ], commonLoaders, [
{
test: /\.svg$/,
loader: "svgo?" + JSON.stringify({
plugins: [
{ removeTitle: true },
{ removeUselessStrokeAndFill: false }
]
})
}
])
},
plugins: [
// NW.js package.json
new CopyWebpackPlugin([
{ from: r( pRoot, "package.json" ) },
{ from: r( pRoot, "drivers", "selenium-server-standalone-3.2.0.jar" ),
to: "drivers" },
{ from: r( pServer, "config"), to: "config"},
{ from: r( pServer, "data"), to: "data"},
]),
new WebpackShell({
onBuildStart: ["npm run babelprod"],
}),
new HtmlWebpackPlugin({
inject: "head",
hash: false,
template: r( pRoot, "index.html" )
}),
// use non-debug versions of ember and ember-data in production builds
new webpack.NormalModuleReplacementPlugin(
/\/ember\/ember\.debug\.js$/,
r( pModulesBower, "ember", "ember.prod.js" )
),
new webpack.NormalModuleReplacementPlugin(
/\/ember-data\/ember-data\.js$/,
r( pModulesBower, "ember-data", "ember-data.prod.js" )
),
// minify
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
warnings: false
},
mangle: {
props: false,
except: ["function*"]
},
beautify: false,
screwIE8: true,
preserveComments: /(?:^!|@(?:license|preserve|cc_on))/
}),
// add license banner
new webpack.BannerPlugin([
"<%= main['display-name'] %>",
"@version v<%= package.version %>",
"@date <%= grunt.template.today('yyyy-mm-dd') %>",
"@copyright <%= package.author %>"
].join( "\n" ), {
entryOnly: true
})
],
// optimize css
lessLoader: {
lessPlugins: [
new LessPluginCleanCSS({
advanced: true
})
]
}
},....
module.exports={
//共同选择
//grunt网页包将“选项”对象与每个任务配置合并(嵌套)
选项:{
统计数据:{
时间:对,
儿童:错
},
上下文:j(“.”,“src”),
输出:{
//按输入模块名称命名每个文件
文件名:“[name].js”,
//不要在sourcemaps中使用webpack://协议
devtoolModuleFilenameTemplate:“/[资源路径]”
},
//进入模块
条目:{
main:“main”,
索引:“索引”
},
决心:{
模块目录:[
“web_模块”,
“节点_模块”,
“bower_组件”
],
别名:{
//文件夹别名
“根”:pRoot,
“服务器”:pServer,
“风格”:pStyles,
“img”:皮马杰,
“模板”:p模板,
“bower”:一种权力,
//应用程序文件夹
“附件”:r(pApp,“附件”),
“认证者”:r(pApp,“认证者”),
“授权人”:r(pApp,“授权人”),
“配置”:r(pApp,“配置”),
“初始设定人”:r(pApp,“初始设定人”),
“混合物”:r(pApp,“混合物”),
“服务”:r(pApp,“服务”),
“助手”:r(pApp,“助手”),
“模型”:r(pApp,“模型”),
“控制器”:r(pApp,“控制器”),
“路线”:r(pApp,“路线”),
“组件”:r(pApp,“组件”),
“存储”:r(pApp,“存储”),
“UTIL”:r(pApp,“UTIL”),
“gui”:r(pApp,“gui”),
“会话存储”:r(pApp,“会话存储”),
“垫片”:r(前置,“垫片”),
“配置2”:r(pRoot,“config”),
}
},
解析加载程序:{
根:pRoot,
模块目录:[
“网络加载器”,
“web_模块”,
“节点加载程序”,
“节点_模块”
]
},
插件:[
//不要将主模块拆分为多个块
新的webpack.optimize.LimitChunkCountPlugin({maxChunks:1}),
//按模块路径拆分为块
新的SplitByPathPlugin([
{
名称:“供应商.鲍尔”,
路径:pModulesBower
},
{
名称:“vendor.npm”,
路径:pModulesNpm
},
{
名称:“模板”,
路径:pTemplates
}
]),
//不要在js包中包含css样式表
cssextractextplugin,
lessExtractTextPlugin,
//忽略momentjs的l10n模块
新的webpack.IgnorePlugin(/^\.\/locale$/,/moment$/)
]
},
// -----
//任务配置
// -----
开发人员:{
输出:{
路径:“
},
决心:{
root:[pApp,pAppServer]
},
目标:“节点webkit”,
devtool:“源地图”,
模块:{
装载机:[].concat([LoaderBaelDev,],CommonLoader),
规则:[
{
测试:/\.js$/,,
使用:[“源地图加载程序”],
强制执行:“预”
}
]
},
插件:[
//NW.js package.json
新的CopyWebpackPlugin([
{from:r(pRoot,“package.json”)},
{from:r(pRoot,“drivers”,“selenium-server-standalone-3.2.0.jar”),
致:“司机”},
{从:r(pRoot,“drivers”,“chromedriver_mac64”)到:“drivers”},
{从:r(pServer,“config”)到:“config”},
{从:r(pServer,“data”)到:“data”},
]),
新网页外壳({
//onBuildStart:[“npm运行巴贝尔”],
onBuildExit:
[`chmod 0755${j(pBuildRoot,“驱动程序/chromedriver_mac64”)}`,
}),
新HtmlWebpackPlugin({
注入:“头”,
哈什:错,
模板:r(pRoot,“index.html”)
}),
新的webpack.DefinePlugin({
是的,
“process.env”:{
“NODE_ENV”:JSON.stringify(“生产”)
}
}),
新的NwjsPlugin({
文件:“/**”,
argv:“--远程调试端口=8888”,
重新运行:是的,
日志:是的,
logStdOut:错,
logStdErr:对
}),
],
手表:没错,
基帕利夫:是的,
失败者:错误
},
产品:{
输出:{
路径:“
},
决心:{
根:pApp
},
目标:“节点webkit”,
模块:{
装载机:[].concat([LoaderBaelProd,],普通装载机[
{
测试:/\.svg$/,,
加载器:“svgo?”+JSON.stringify({
插件:[
{removetille:true},
module.exports = {
// common options
// the grunt-webpack merges the "options" objects with each task config (nested)
options: {
stats: {
timings: true,
children: false
},
context: j( ".", "src" ),
output: {
// name each file by their entry module name
filename: "[name].js",
// don't use the webpack:// protocol in sourcemaps
devtoolModuleFilenameTemplate: "/[resource-path]"
},
// the entry module
entry: {
main: "main",
index: "index"
},
resolve: {
modulesDirectories: [
"web_modules",
"node_modules",
"bower_components"
],
alias: {
// folder aliases
"root" : pRoot,
"server" : pServer,
"styles" : pStyles,
"img" : pImages,
"templates" : pTemplates,
"bower" : pModulesBower,
// app folders
"addons" : r( pApp, "addons" ),
"authenticators" : r( pApp, "authenticators" ),
"authorizers" : r( pApp, "authorizers" ),
"config" : r( pApp, "config" ),
"initializers": r( pApp, "initializers" ),
"mixins" : r( pApp, "mixins" ),
"services" : r( pApp, "services" ),
"helpers" : r( pApp, "helpers" ),
"models" : r( pApp, "models" ),
"controllers" : r( pApp, "controllers" ),
"routes" : r( pApp, "routes" ),
"components" : r( pApp, "components" ),
"store" : r( pApp, "store" ),
"utils" : r( pApp, "utils" ),
"gui" : r( pApp, "gui" ),
"session-stores" : r( pApp, "session-stores" ),
"shim" : r( pRoot, "shim" ),
"config2" : r( pRoot, "config" ),
}
},
resolveLoader: {
root: pRoot,
modulesDirectories: [
"web_loaders",
"web_modules",
"node_loaders",
"node_modules"
]
},
plugins: [
// don't split the main module into multiple chunks
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
// split into chunks by module path
new SplitByPathPlugin([
{
name: "vendor.bower",
path: pModulesBower
},
{
name: "vendor.npm",
path: pModulesNpm
},
{
name: "templates",
path: pTemplates
}
]),
// don't include css stylesheets in the js bundle
cssExtractTextPlugin,
lessExtractTextPlugin,
// ignore l10n modules of momentjs
new webpack.IgnorePlugin( /^\.\/locale$/, /moment$/ )
]
},
// -----
// task configs
// -----
dev: {
output: {
path: "<%= dir.tmp_dev %>"
},
resolve: {
root: [pApp, pAppServer]
},
target: "node-webkit",
devtool: "source-map",
module: {
loaders: [].concat( [ loaderBabelDev, ], commonLoaders ),
rules: [
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre"
}
]
},
plugins: [
// NW.js package.json
new CopyWebpackPlugin([
{ from: r( pRoot, "package.json" ) },
{ from: r( pRoot, "drivers", "selenium-server-standalone-3.2.0.jar" ),
to: "drivers" },
{ from: r( pRoot, "drivers", "chromedriver_mac64" ), to: "drivers" },
{ from: r( pServer, "config"), to: "config"},
{ from: r( pServer, "data"), to: "data"},
]),
new WebpackShell({
//onBuildStart: ["npm run babel"],
onBuildExit:
[`chmod 0755 ${j(pBuildRoot, "drivers/chromedriver_mac64")}`],
}),
new HtmlWebpackPlugin({
inject: "head",
hash: false,
template: r( pRoot, "index.html" )
}),
new webpack.DefinePlugin({
DEBUG: true,
"process.env":{
"NODE_ENV": JSON.stringify("production")
}
}),
new NwjsPlugin({
files: "<%= dir.tmp_dev %>/**",
argv: "--remote-debugging-port=8888",
rerunOnExit: true,
log: true,
logStdOut: false,
logStdErr: true
}),
],
watch: true,
keepalive: true,
failOnError: false
},
prod: {
output: {
path: "<%= dir.tmp_prod %>"
},
resolve: {
root: pApp
},
target: "node-webkit",
module: {
loaders: [].concat( [ loaderBabelProd, ], commonLoaders, [
{
test: /\.svg$/,
loader: "svgo?" + JSON.stringify({
plugins: [
{ removeTitle: true },
{ removeUselessStrokeAndFill: false }
]
})
}
])
},
plugins: [
// NW.js package.json
new CopyWebpackPlugin([
{ from: r( pRoot, "package.json" ) },
{ from: r( pRoot, "drivers", "selenium-server-standalone-3.2.0.jar" ),
to: "drivers" },
{ from: r( pServer, "config"), to: "config"},
{ from: r( pServer, "data"), to: "data"},
]),
new WebpackShell({
onBuildStart: ["npm run babelprod"],
}),
new HtmlWebpackPlugin({
inject: "head",
hash: false,
template: r( pRoot, "index.html" )
}),
// use non-debug versions of ember and ember-data in production builds
new webpack.NormalModuleReplacementPlugin(
/\/ember\/ember\.debug\.js$/,
r( pModulesBower, "ember", "ember.prod.js" )
),
new webpack.NormalModuleReplacementPlugin(
/\/ember-data\/ember-data\.js$/,
r( pModulesBower, "ember-data", "ember-data.prod.js" )
),
// minify
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
warnings: false
},
mangle: {
props: false,
except: ["function*"]
},
beautify: false,
screwIE8: true,
preserveComments: /(?:^!|@(?:license|preserve|cc_on))/
}),
// add license banner
new webpack.BannerPlugin([
"<%= main['display-name'] %>",
"@version v<%= package.version %>",
"@date <%= grunt.template.today('yyyy-mm-dd') %>",
"@copyright <%= package.author %>"
].join( "\n" ), {
entryOnly: true
})
],
// optimize css
lessLoader: {
lessPlugins: [
new LessPluginCleanCSS({
advanced: true
})
]
}
},....