自从将webpack升级到版本3并将其他软件包升级到各自的最新版本后,我收到错误消息。我用这个办公用ui面料的应用程序反应,但我找不到错误。根据我的理解,我的块的加载顺序是正确的,所以这里有什么问题?
这是我的webpack配置:
var webpack = require('webpack');
var path = require('path');
var config = {
entry: {
vendor: ["jquery", "react", "react-dom", "office-ui-fabric-react"]
},
//watch: true,
output: {
path: __dirname + "/dist",
filename: './[name].js'
},
devtool: 'source-map',
devServer: {
contentBase: path.resolve(__dirname, './dist')
},
resolve: {
alias: {
Content: path.resolve(__dirname, "Content")
},
extensions: ['.ts', '.tsx', '.js']
},
plugins: [
new webpack.optimize.CommonsChunkPlugin("vendor")
],
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{ loader: "ts-loader" }
]
},
{
test: /\.scss$/,
use: [
{ loader: "style-loader" },
{ loader: "css-loader" },
{ loader: "sass-loader" }
]
},
{
test: /\.css$/,
use: [
{ loader: "style-loader" },
{ loader: "css-loader" }
]
}
]
}
}
config.entry.projectrecord = "./src/apps/csr_projects";
config.entry.contractcsr = "./src/apps/csr_contracts";
config.entry.finance = "./src/apps/finance";
config.entry.wpreviewer = "./src/apps/wpreviewer";
module.exports = config;
我的package.json
{
"name": "MyApp",
"version": "1.0.0",
"description": "SharePoint Add-In",
"main": "index.js",
"types": "main.d.ts",
"repository": "repo_url",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Me",
"license": "UNLICENSED",
"devDependencies": {
"@types/jquery": "~3.2.16",
"@types/react": "16.0.25",
"@types/react-dom": "^16.0.3",
"@types/sharepoint": "^2016.0.2",
"@uifabric/icons": "^5.2.0",
"css-loader": "^0.28.7",
"jquery": "^3.2.1",
"load-themed-styles": "^1.2.0",
"node-sass": "^4.7.1",
"office-ui-fabric-react": "^5.23.0",
"raw-loader": "^0.5.1",
"react": "^16.1.1",
"react-dom": "^16.1.1",
"sass-loader": "^6.0.6",
"style-loader": "^0.19.0",
"systemjs": "^0.20.19",
"ts-loader": "^3.1.1",
"typescript": "~2.6.1",
"webpack": "~3.8.1",
"webpack-dev-server": "^2.9.4"
},
"dependencies": {}
}
编辑:问题只存在于IE中。 Chrome和FF在解析生成的脚本时没有任何问题。
编辑2:当我使用prod构建时,我的供应商包中出现“Set is undefined”错误。 IE似乎不支持这一点。我已经在我的webpack配置中包含了一个set polyfill,但错误仍然存在。