我的webpack.config.js文件具有以下配置:
module:
{
loaders:
[
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'},
{ test: /\.json$/, loaders: ['json-loader'] },
{ test: /\.svg$/, loader: 'url?limit=65000&mimetype=image/svg+xml' },
{ test: /\.eot$/, loader: 'url?limit=65000&mimetype=application/vnd.ms-fontobject' },
{ test: /\.png$/, loader: 'url?limit=65000&mimetype=image/png' },
{ test: /\.css$/, loader: "style-loader!css-loader" }
]
}
我需要从管道常规脚本读取装入程序部分。我已经尝试过以下正则表达式,但是它不起作用。有人可以帮我吗?
def findStr = "(?<=loaders:)(\\[)(.*)(\\])"
File file = new File('C:/Tools/filewrite/webpack.local.config.js')
def lines = file.readLines();
StringBuilder strBuild = new StringBuilder();
lines.each { String lineS ->
strBuild.append(lineS)
}
def webpackContent = strBuild.toString();
Pattern p = Pattern.compile(findStr);
Matcher m = p.matcher(webpackContent);
while(m.find())
{
def str = m.group();
echo "${str}";
}
注意:
同一程序在Eclipse groovy项目中可以正常运行,但不能 在Jenkins管道脚本中工作。