执行自动Team City部署时,我们看到一个错误,特别是与Webpack有关的事情。打印的输出:
[19:12:56]
(node:5308) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
[19:12:56]
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
[19:12:58]
ts-loader: Using typescript@2.9.2 and C:\TeamCity\buildAgent\work\80d0099932f101d3\tsconfig.json
[19:13:38]
Process exited with code 2
我们能够确定弃用警告不相关,并且可以使该警告根本不出现,但是它不会影响最终结果;我们仍然会收到代码2的错误。此问题大约在4个月前开始发生,我们不确定为什么。当我在本地运行webpack开发版本时,我也会看到“进程终止于代码2”,但我的同事却没有。我们比较了webpack.config.js
和package.json
,它们是相同的。我们目前还不确定要检查什么。
关于为什么会发生这种情况以及要检查什么的任何想法?以下是我们的package.json。 更新:Webpack.config.js包含在其下。
Package.json
{
"name": "Redacted",
"version": "1.0.0",
"description": "Redacted Website",
"main": "gulpfile.js",
"dependencies": {
"async": "^1.5.2",
"backbone": "^1.3.3",
"backbone.marionette": "^3.0.0",
"backbone.radio": "^2.0.0",
"bluebird": "^3.4.1",
"bootstrap-sass": "^3.3.7",
"bootstrap-validator": "^0.11.9",
"font-awesome": "^4.7.0",
"glob": "^7.0.3",
"gulp": "^3.9.0",
"gulp-autoprefixer": "^3.1.0",
"gulp-debug": "^2.1.2",
"gulp-exec": "^2.1.2",
"gulp-foreach": "^0.1.0",
"gulp-load-plugins": "^1.0.0",
"gulp-msbuild": "0.4.4",
"gulp-newer": "^1.0.0",
"gulp-rename": "^1.2.2",
"gulp-rimraf": "^0.2.0",
"gulp-sass": "^2.0.4",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.5",
"jquery": "^3.0.0",
"jquery-datepicker": "1.11.4",
"merge-stream": "^1.0.0",
"nunjucks": "^3.0.0",
"nunjucks-loader": "^2.4.5",
"rimraf": "^2.4.3",
"run-sequence": "^1.1.4",
"saas": "^1.0.0",
"slick-carousel": "^1.8.1",
"underscore": "^1.8.3",
"vinyl": "^1.1.0",
"webpack-strip": "^0.1.0",
"xml2js": "^0.4.16",
"xmlpoke": "^0.1.12",
"yargs": "^6.4.0"
},
"devDependencies": {
"@types/backbone": "^1.3.33",
"@types/backbone.marionette": "0.0.20",
"@types/backbone.radio": "^0.8.32",
"@types/bluebird": "^3.0.35",
"@types/bootstrap": "^3.3.32",
"@types/chai": "^4.0.4",
"@types/jasmine": "^2.5.38",
"@types/jquery": "^2.0.34",
"@types/karma": "^1.7.1",
"@types/mocha": "^2.2.44",
"@types/node": "^6.0.49",
"@types/nunjucks": "0.0.32",
"@types/underscore": "^1.7.33",
"bourbon": "^4.2.7",
"breakpoint-sass": "^2.7.1",
"chai": "^4.1.2",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.23.1",
"extract-text-webpack-plugin": "^2.0.0-rc.2",
"file-loader": "^0.9.0",
"gulp-nuget-restore": "^0.4.0",
"jasmine": "^2.5.3",
"jasmine-core": "^2.4.1",
"json-loader": "^0.5.4",
"karma": "^1.4.1",
"karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "^1.1.0",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.5",
"mocha": "^4.0.1",
"node-sass": "^3.13.1",
"sass-loader": "^4.0.0",
"style-loader": "^0.13.1",
"ts-loader": "^0.8.2",
"typescript": "^2.0.0",
"webpack": "^2.7.0",
"webpack-bundle-tracker": "0.0.93",
"webpack-dev-server": "^1.14.1"
},
"scripts": {
"test": "./node_modules/.bin/karma start",
"start": "./node_modules/.bin/webpack --config webpack.config.js --watch",
"build": "WEBPACK_ENV=production ./node_modules/.bin/webpack --config webpack.config.js",
"dev": "./node_modules/.bin/webpack-dev-server --config webpack.config.js --port 9000 --host 0.0.0.0 --content-base dev/ --hot --inline --progress --colors"
},
"repository": {
"type": "git",
"url": "git+{our git url redacted}"
},
"author": "Redacted",
"license": "ISC"
}
Webpack.config.js
var webpack = require("webpack");
var path = require("path");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var BundleTracker = require("webpack-bundle-tracker");
var CopyWebpackPlugin = require('copy-webpack-plugin');
/**
* Webpack Docs:
* - https://webpack.js.org/configuration/
* - https://webpack.js.org/guides/migrating/ (1.x -> 2.x)
*/
var publicPath = '/static/';
var config = {
context: path.resolve(__dirname),
entry: {
// necessary to copy image files to /static, see README.md
"imgs": "./src/Project/Redacted.Website/code/@static/@imgs/index.js",
"js/common": "common/index.js",
"css/common": "common/index.scss",
"js/ui-kit": "ui-kit/index.js",
"css/ui-kit": "ui-kit/index.scss",
"js/home": "home/index.js",
"css/home": "home/index.scss",
"js/landing-hero-slider": "landing-hero-slider/index.js",
"js/nav-pinned": "nav-pinned/index.js",
"js/curriculum-wheel": "curriculum-wheel/index.js",
"js/meet-us-form": "meet-us-form/index.js",
"js/action-slider": "action-slider/index.js",
"js/meet-teachers-module-slider": "meet-teachers-module-slider/index.js",
"js/testimonials-slider": "testimonials-slider/index.js",
"js/events-module-slider": "events-module-slider/index.js",
"js/curriculum-module-slider": "curriculum-module-slider/index.js",
"js/awards-module-slider": "awards-module-slider/index.js",
"js/sample-lunch-module-slider": "sample-lunch-module-slider/index.js",
"js/faq": "faq/index.js",
"js/about-welcome-slider": "about-welcome-slider/index.js",
"js/see-more": "see-more/index.js",
"js/curriculum-wheel-tabbed": "curriculum-wheel-tabbed/index.js",
"js/curriculum-tabbed-slider": "curriculum-tabbed-slider/index.js",
"js/curriculum-tabbed-mobile-select": "curriculum-tabbed-mobile-select/index.js",
"js/curriculum-tabbed-text-scroller": "curriculum-tabbed-text-scroller/index.js",
"js/lead-form-module": "lead-form-module/index.js",
"js/lead-form-in-page": "lead-form-in-page/index.js",
"js/lead-form-progressive-disclosure": "lead-form-progressive-disclosure/index.js",
"js/passcode-modal": "passcode-modal/index.js",
},
output: {
path: path.resolve(__dirname, "./src/Project/Redacted.Website/code/static"),
filename: "[name].js",
publicPath: publicPath,
chunkFilename: "[id].chunck.[ext]"
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: "js/common",
filename: "js/common.js"
}),
new ExtractTextPlugin({filename: "[name].css"}),
new BundleTracker({filename: "../../webpack-stats.json"}),
new webpack.ProvidePlugin({
"fetch": "imports?this=>global!exports?global.fetch!whatwg-fetch",
"Promise": "bluebird",
"$": "jquery", // bootstrap.js support
"jQuery": "jquery", // bootstrap.js support
}),
// SEE: https://github.com/kevlened/copy-webpack-plugin
new CopyWebpackPlugin([
// { "from": "@copy/path/to/file.ext", "to": "path/to/file.ext"},
]),
],
module: {
rules: [
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
use: [{
loader: "css-loader", options: { minimize: true }
}, {
loader: "sass-loader",
options: {
data: "$staticUrl: '" + publicPath + "';"
}
}]
})
},
{
test: /\.tsx?/,
exclude: /node_modules/,
use: "ts-loader"
},
{
test: /\.(woff2?|eot|ttf|svg)(\?\S*)?$/,
exclude: [
path.resolve(__dirname, "@imgs")
],
use: [
{
loader: "file-loader",
options: {
name: "fonts/[name].[ext]",
}
}
]
},
{
test: /\.(png|gif|jpe?g|svg)$/i,
exclude: [
path.resolve(__dirname, "node_modules")
],
use: [
{
loader: "file-loader",
options: {
name: "imgs/[name].[ext]",
}
}
]
},
{
test: /\.(njk|nunjucks)$/,
exclude: /node_modules/,
use: {
loader: "nunjucks-loader",
options: {
config: path.resolve(__dirname, "nunjucks.config.js")
}
}
}
]
},
devtool: "source-map",
resolve: {
extensions: [".webpack.js", "web.js", ".ts", ".tsx", ".js"],
alias: {
"webworkify": "webworkify-webpack",
"bootstrap": "bootstrap-sass/assets/javascripts/bootstrap",
"bootstrap-styles": "bootstrap-sass/assets/stylesheets",
"breakpoint-styles": "breakpoint-sass/stylesheets",
"bourbon-styles": "bourbon/app/assets/stylesheets",
},
modules: ["node_modules", "./src/Project/Redacted.Website/code/@static/@modules", "./src/Project/Redacted.Website/code/@static/@css", "./src/Project/Redacted.Website/code/@static/@imgs", "./src/Project/Redacted.Website/code/@static/@tests"]
}
}
//if (process.env.WEBPACK_ENV == 'production'){
config.plugins = config.plugins.concat([
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false,
unsafe_comps: true,
unsafe: true,
pure_getters: true
},
comments: false,
sourceMap: true
})
])
config.module.rules = config.module.rules.concat([
{
test: /\.(js|ts)$/,
loader: "webpack-strip?strip[]=console.warn,strip[]=console.log"
},
])
//}
module.exports = config