晚上好, 我有个问题。我正在做一个React项目,在对代码进行了一些更改之后,我想将其部署到暂存中。 我运行了命令
gulp部署--scripts --styles --staging
此后,当达到业障并返回此错误时,它将失败:
22 10 2018 19:39:11.114:ERROR [预处理]:无法加载“ webpack”! WebpackOptionsValidationError:无效的配置对象。已使用与API模式不匹配的配置对象初始化Webpack。 -configuration.entry应该是以下之一: 对象{:非空字符串| [非空字符串]} |非空字符串| [非空字符串] |功能 编译的入口点。 细节: * configuration.entry的属性不得少于1个({ “ keyword”:“ minProperties”, “ dataPath”:“ .entry”, “ schemaPath”:“#/ oneOf / 0 / minProperties”, “参数”:{ “限制”:1 }, “ message”:“属性不得少于1个”, “模式”:1, “ parentSchema”:{ “ minProperties”:1 “ additionalProperties”:{ “ oneOf”:[ { “ description”:“该字符串解析为启动时加载的模块。”, “ minLength”:1 “ type”:“字符串” }, { “ description”:“所有模块在启动时均已加载。最后一个模块已导出。”, “ $ ref”:“#/ definitions / common.nonEmptyArrayOfUniqueStringValues” } ] }, “ description”:“创建了多个条目包。键是块名称。值可以是字符串或数组。”, “ type”:“对象” }, “数据”:{} }。 对象{:非空字符串| [非空字符串]} 创建了多个条目束。关键是块名称。该值可以是字符串或数组。 * configuration.entry应该是一个字符串。 * configuration.entry应该是一个数组: [非空字符串] * configuration.entry应该是函数的实例 返回入口对象或promise的函数。
到目前为止,我还没有与Karma合作过,我真的不确定在这里做什么或可能是什么问题。
我的webpack版本是2.15.5,npm是2.15.5,业力2.15.5和节点v4.4.6。
这是karma.conf.js
'use strict';
const path = require('path');
const pathTo = path.join.bind(null, process.cwd());
module.exports = function(config) {
config.set({
// base path is app/ so node_modules/ don't get included
basePath: pathTo('app'),
files: [
//'**/__tests__/**/*.js'
'tests/tests.webpack.js'
],
frameworks: ['mocha', 'sinon-chai', 'chai-jquery', 'chai', 'jquery-2.1.0'],
browsers: ['PhantomJS'], // or open localhost:9876 in any browser installed
reporters: ['mocha'],
mochaReporter: {
output: 'autowatch' // 'autowatch' or 'minimal'
},
preprocessors: {
//'**/__tests__/**/*.js': ['webpack']
'tests/tests.webpack.js': ['webpack']
},
webpack: {
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
include: [
path.join(__dirname, 'app', 'react'),
path.join(__dirname, 'app', 'tests'),
path.join(__dirname, 'app', 'scripts', '__tests__')
],
query: {
presets: ['es2015', 'react'],
compact: true
}
}]
}
},
webpackServer: {
noInfo: true
}
});
};
这是我的webpack.config.js
'use strict';
const webpack = require('webpack');
const StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin');
const path = require('path');
//const config = require('./config');
const data = require('./app/react/data');
const yargs = require('yargs');
const arg = yargs.argv;
const config = {
production: arg.prod,
development: arg.dev || (!arg.prod && !arg.pages),
pages: arg.pages,
watch: arg.watch
};
// Add Node env. variables to data object so they can be passed and accessed in React.
const dataConfig = Object.assign({}, data, {
dev: config.development,
prod: config.production,
pages: config.pages,
watch: config.watch
});
function getValues(obj) {
const allPaths = [];
Object.keys(obj).forEach(key => allPaths.push(obj[key]));
return allPaths;
}
/**
* If --pages flag is passed, webpack will load and generate content pages only and ignore
* --prod and --dev flags. Else, it will choose dev or prod settings accordingly
*/
const routes = config.pages ? getValues(data.staticPaths) :
(config.development ? getValues({ INDEX: '/' }) : getValues(data.prodPaths));
let htmlDir = 'build';
if (arg.pages) {
htmlDir = 'dist/pages';
} else if (arg.prod) {
htmlDir = 'dist/templates';
}
module.exports = {
entry: {
main: path.join(__dirname, 'app', 'react', 'Router.js'),
dev: path.join(__dirname, 'app', 'react', 'devApp.js')
},
output: {
filename: '[name].bundle.js',
path: path.join(__dirname, htmlDir),
libraryTarget: 'umd',
publicPath: '/'
},
// rebuild on change
watch: false,
// true by default with watch: true
cache: true,
// source map makes sense only when bundle.js is used on page,
// we don't need it for generating html
devtool: '#source-map',
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
include: [
path.join(__dirname, 'app', 'react'),
path.join(__dirname, 'app', 'data')
],
query: {
presets: ['es2015', 'react'],
compact: true
}
},
{
test: /\.md$/,
loader: 'html!markdown?gfm=false',
include: [
path.join(__dirname, 'app', 'data')
]
},
{
test: /\.json$/,
loader: 'json',
include: [
path.join(__dirname, 'app', 'react'),
path.join(__dirname, 'app', 'data')
]
}
]
},
plugins: [
new StaticSiteGeneratorPlugin('main', routes, dataConfig),
new webpack.DefinePlugin({
'process.env': {
'MOCK': arg.mock
}
})
]
};
我希望有人可以帮助我。