我在項(xiàng)目webpack的升級(jí)過(guò)程中,遇到了問(wèn)題,就是打包到最后,會(huì)報(bào)出錯(cuò)誤:
我總感覺(jué)第一個(gè)錯(cuò)誤是某個(gè)低級(jí)失誤導(dǎo)致的,但是一直不知道哪里出了問(wèn)題,package.json文件應(yīng)該書(shū)寫(xiě)正常的:
{
"name": "mercury",
"version": "4.5.0",
"scripts": {
"buildlib": "yarn buildlib:prod",
"buildlib:debug": "NODE_ENV=debug webpack --config webpack.dll.config.js",
"buildlib:prod": "NODE_ENV=production webpack --config webpack.dll.config.js",
"prestart": "cp -rv src/vendors/* dist/",
"start": "cp deploy/env/dev/config.env.js src/scripts/common/config.env.js && webpack-dev-server --inline --progress",
"build": "yarn build:prod",
"build:debug": "COMMIT_ID=$(git rev-parse --short HEAD) NODE_ENV=debug webpack --progress --profile --colors",
"build:prod": "COMMIT_ID=$(git rev-parse --short HEAD) NODE_ENV=production webpack --progress --profile --colors",
"config": "yarn config:production",
"config:development": "NODE_ENV=development node bin/get_config.js",
"config:production": "NODE_ENV=production node bin/get_config.js",
"upload": "node bin/upload_oss.js",
"debug": "yarn buildlib:debug && yarn build:debug && yarn prestart && mkdir -p public && cp -R dist/* public/",
"lint:git": "eslint `git diff-index --name-only HEAD | grep -E '.(js|jsx)$'`",
"lint": "eslint --ext .js --ext .jsx .",
"lint:fix": "eslint --fix --ext .js --ext .jsx .",
"precommit": "npm run lint:git",
"inspect": "jsinspect ./src/scripts",
"commitmsg": "commit-message-validator"
},
"config": {
"commit-message-validator": {
"pattern": [
"^\\s*refs\\s+#SMART-\\d+\\s+.+$"
]
}
},
"devDependencies": {
"add-asset-html-webpack-plugin": "^2.0.1",
"aliyun-sdk": "^1.11.2",
"babel-core": "^6.1.2",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.1.4",
"babel-plugin-antd": "^0.4.0",
"babel-plugin-import": "^1.2.1",
"babel-plugin-transform-runtime": "^6.4.3",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.1.2",
"babel-preset-react": "^6.1.2",
"babel-preset-stage-0": "^6.5.0",
"babel-runtime": "^6.3.19",
"commit-message-validator": "^0.1.6",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^2.0.1",
"css-loader": "^0.28.11",
"eslint": "^4.18.1",
"eslint-config-standard": "^11.0.0",
"eslint-import-resolver-webpack": "^0.8.1",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-jsx-a11y": "^5.0.1",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-react": "^6.10.3",
"eslint-plugin-standard": "^3.0.1",
"extract-text-webpack-plugin": "next",
"file-loader": "^1.1.11",
"happypack": "next",
"html-loader": "^0.4.4",
"html-webpack-plugin": "^3.2.0",
"husky": "^0.13.3",
"jsinspect": "^0.12.7",
"json-loader": "^0.5.7",
"merge-stream": "^1.0.0",
"mime": "^2.2.0",
"node-sass": "^3.4.1",
"react-hot-loader": "^1.3.1",
"sass-loader": "^6.0.7",
"style-loader": "^0.20.3",
"url-loader": "^1.0.1",
"walkdir": "^0.0.12",
"webpack": "4",
"webpack-cli": "^2.0.14",
"webpack-dev-server": "3.1.1"
},
"dependencies": {
"antd": "2.11.0",
"autosize": "^3.0.20",
"better-scroll": "^1.8.1",
"fast-uglifyjs-plugin": "^0.3.0",
"fingerprintjs2": "^1.6.1",
"font-awesome": "^4.4.0",
"history": "^2.1.2",
"lodash.chunk": "^4.2.0",
"lodash.clonedeep": "^4.5.0",
"lodash.merge": "^4.6.0",
"mini-css-extract-plugin": "^0.4.0",
"moment-timezone": "^0.5.14",
"node-uuid": "^1.4.7",
"raven-js": "^3.21.0",
"react": "^15.6.1",
"react-dipper": "^0.1.3",
"react-dom": "^15.6.1",
"react-id-swiper": "^1.5.8",
"react-iframe": "^1.1.0",
"react-mixin": "^3.0.3",
"react-redux": "^4.0.0",
"react-refetch": "^1.0.0-beta.10",
"react-router": "^2.6.0",
"redux": "^3.0.4",
"redux-thunk": "^1.0.0",
"socket.io": "^2.0.4",
"store": "^1.3.17",
"underscore": "^1.8.3",
"webpack-sentry-plugin": "^1.14.1",
"whatwg-fetch": "^2.0.1"
}
}
webpack.config.js是這樣的:
var path = require('path');
var fs = require('fs');
var webpack = require('webpack');
var ExtractTextWebapckPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var FastUglifyJsPlugin = require('fast-uglifyjs-plugin');
var SentryPlugin = require('webpack-sentry-plugin');
var LibManifestJson = require('./lib-manifest.json');
var sassExtract = new ExtractTextWebapckPlugin('css/sass.css');
const isDebug = process.env.NODE_ENV === 'debug';
const isProduct = isDebug || process.env.NODE_ENV === 'production';
var HappyPack = require('happypack');
var happyThreadPool = HappyPack.ThreadPool({ size: isProduct ? 3 : 1 });
let publicPath = '/';
if (fs.existsSync('./config.local.js')) {
const consulConfig = require('./config.local');
publicPath = `${consulConfig.cdn.static}/apollon/assets/`;
}
var entry = {
app: ['whatwg-fetch', './src/scripts/index.js'],
};
if (!isProduct) {
entry.app.push('webpack/hot/only-dev-server');
}
var config = {
devtool: '#eval-source-map',
mode: 'development',
entry,
output: {
path: path.resolve(__dirname, './dist'),
publicPath,
filename: 'js/[name].js',
},
resolve: {
modules: [
path.resolve('./src/scripts'),
path.resolve('./src'),
'node_modules',
],
extensions: ['*', '.js', '.scss', '.css', '.json'],
alias: {
containers: path.resolve(__dirname, './src/scripts/containers'),
components: path.resolve(__dirname, './src/scripts/components'),
},
},
module: {
rules: [
{
test: /\.html$/,
loader: 'html-loader',
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'happypack/loader?id=happybabel',
},
{
test: /\.json$/,
exclude: /node_modules/,
loader: 'json-loader',
},
{
test: /\.css$/,
use: ExtractTextWebapckPlugin.extract({
use: 'css-loader'
})
},
{
test: /\.scss$/,
use: sassExtract.extract({ use: ['css-loader', 'sass-loader'] })
},
{
test: /\.(otf|eot|svg|ttf|woff2?)(\?.*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
name: 'fonts/[name].[hash:7].[ext]',
},
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
query: {
limit: 15000,
name: 'images/[name].[hash:7].[ext]',
},
},
],
},
plugins: [
new CopyWebpackPlugin([
{ from: 'src/images', to: 'images' },
]),
new HappyPack({
id: 'happybabel',
loaders: ['babel-loader'],
threadPool: happyThreadPool,
verbose: true,
}),
],
};
if (isProduct) {
config.devtool = isDebug ? 'source-map' : '(none)';
config.mode = 'production';
config.output = Object.assign({}, config.output, {
filename: 'js/[name].[chunkhash].js',
chunkFilename: '[id].[chunkhash].js',
});
config.plugins = (config.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"',
},
}),
new FastUglifyJsPlugin({
compress: {
warnings: false,
drop_console: true,
},
debug: true,
workerNum: 1,
sourceMap: isDebug,
}),
new ExtractTextWebapckPlugin({ filename: 'css/[name].[contenthash].css', allChunks: true }),
new webpack.DllReferencePlugin({
context: __dirname,
manifest: LibManifestJson,
}),
new HtmlWebpackPlugin({
filename: path.resolve(__dirname, './dist/index.html'),
favicon: './src/images/favicon.ico',
template: 'index.html',
inject: 'body',
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency',
}),
new AddAssetHtmlPlugin({ filepath: require.resolve('./src/vendors/lib.dll.js'), includeSourcemap: false, hash: true, publicPath }),
new SentryPlugin({
organization: 'sentry',
project: 'apollon-frontend',
apiKey: 'ba56369e62fc4c22a71b3e8e8157cf86ab8b689cc7174aa68cf9b9c5f85d6b3f',
// include: /\.js$/,
include: /bundle-.*\.js.*/,
release: process.env.COMMIT_ID,
baseSentryURL: 'https://sentry.smartstudy.com/api/0',
}),
]);
} else {
var proxyHost = require('./src/scripts/common/config.js').webpackProxyHost;
config.devServer = {
contentBase: path.resolve(__dirname, './dist'),
port: 3456,
host: '0.0.0.0',
hot: true,
stats: {
children: false,
},
disableHostCheck: true,
historyApiFallback: true,
noInfo: true,
proxy: [
{
context: ['/api/**'],
target: proxyHost,
changeOrigin: true,
},
],
};
config.plugins = (config.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"development"',
},
}),
new webpack.DllReferencePlugin({
context: __dirname,
manifest: LibManifestJson,
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new ExtractTextWebapckPlugin({ filename: 'css/[name].css', allChunks: true }),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
favicon: path.resolve(__dirname, './src/images/favicon.ico'),
inject: 'body',
}),
new AddAssetHtmlPlugin({ filepath: require.resolve('./src/vendors/lib.dll.js'), includeSourcemap: false, hash: true }),
]);
}
process.traceDeprecation = true;
module.exports = config;
請(qǐng)各位大佬幫忙查看一下可能的問(wèn)題,跪謝啦。。。
北大青鳥(niǎo)APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專(zhuān)業(yè)的國(guó)家
北大青鳥(niǎo)中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團(tuán)創(chuàng)建于1999年,經(jīng)過(guò)二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機(jī)構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團(tuán),成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
曾工作于聯(lián)想擔(dān)任系統(tǒng)開(kāi)發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_(kāi)發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開(kāi)發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開(kāi)發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開(kāi)發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問(wèn),美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。