const path = require('path');
const os = require('os');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HappyPack = require('happypack');
var happyThreadPool = HappyPack.ThreadPool({ size: os.cpus().length });
function resolve (dir) {
return path.join(__dirname, dir);
}
module.exports = {
entry: {
main: '@/main',
'vender-base': '@/vendors/vendors.base.js',
'vender-exten': '@/vendors/vendors.exten.js'
},
output: {
path: path.resolve(__dirname, '../dist/dist')
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
css: 'vue-style-loader!css-loader',
less: 'vue-style-loader!css-loader!less-loader'
},
postLoaders: {
html: 'babel-loader'
}
}
},
{
test: /iview\/.*?js$/,
loader: 'happypack/loader?id=happybabel',
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'happypack/loader?id=happybabel',
exclude: /node_modules/
},
{
test: /\.js[x]?$/,
include: [resolve('src')],
exclude: /node_modules/,
loader: 'happypack/loader?id=happybabel'
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: ['css-loader?minimize', 'autoprefixer-loader'],
fallback: 'style-loader'
})
},
{
test: /\.less$/,
use: ExtractTextPlugin.extract({
use: ['css-loader?minimize','autoprefixer-loader', 'less-loader'],
fallback: 'style-loader'
}),
},
{
test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
loader: 'url-loader?limit=1024'
},
{
test: /\.(html|tpl)$/,
loader: 'html-loader'
}
]
},
plugins: [
new HappyPack({
id: 'happybabel',
loaders: ['babel-loader'],
threadPool: happyThreadPool,
verbose: true
})
],
resolve: {
extensions: ['.js', '.vue'],
alias: {
'vue': 'vue/dist/vue.esm.js',
'@': resolve('../src'),
}
}
};
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const cleanWebpackPlugin = require('clean-webpack-plugin');
const UglifyJsParallelPlugin = require('webpack-uglify-parallel');
const merge = require('webpack-merge');
const webpackBaseConfig = require('./webpack.base.config.js');
const os = require('os');
const fs = require('fs');
const path = require('path');
const package = require('../package.json');
fs.open('./build/env.js', 'w', function(err, fd) {
const buf = 'export default "production";';
fs.write(fd, buf, 0, buf.length, 0, function(err, written, buffer) {});
});
module.exports = merge(webpackBaseConfig, {
output: {
publicPath: './', // 修改 https://iv...admin 這部分為你的服務(wù)器域名
filename: '[name].[hash].js',
chunkFilename: '[name].[hash].chunk.js'
},
plugins: [
new cleanWebpackPlugin(['dist/*'], {
root: path.resolve(__dirname, '../')
}),
new ExtractTextPlugin({
filename: '[name].[hash].css',
allChunks: true
}),
new webpack.optimize.CommonsChunkPlugin({
// name: 'vendors',
// filename: 'vendors.[hash].js'
name: ['vender-exten', 'vender-base'],
minChunks: Infinity
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new HtmlWebpackPlugin({
title: 'Watch Dog' + package.version,
favicon: './ico.png',
filename: '../index.html',
template: '!!ejs-loader!./src/template/index.ejs',
inject: false
})
]
});
0 info it worked if it ends with ok
1 verbose cli [ 'D:\\softs\\nodejs\\node.exe',
1 verbose cli 'D:\\softs\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using npm@5.6.0
3 info using node@v8.11.1
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle watch-dog@1.0.0~prebuild: watch-dog@1.0.0
6 info lifecycle watch-dog@1.0.0~build: watch-dog@1.0.0
7 verbose lifecycle watch-dog@1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle watch-dog@1.0.0~build: PATH: D:\softs\nvm\v8.11.1\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;E:\dev\vue\watchDog-framework-web\node_modules\.bin;D:\softs\Python\Python35\Scripts\;D:\softs\Python\Python35\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\bin\Intel64;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\MinGW\bin;E:\lua5.3;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;D:\softs\Git\cmd;D:\softs\TortoiseGit\bin;D:\softs\apache-maven-3.5.2\bin;D:\softs\nvm;D:\softs\nodejs;D:\softs\MongoDB\Server\3.6\bin;C:\Users\Administrator\AppData\Local\Yarn\bin;D:\softs\Redis\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;D:\softs\Microsoft VS Code\bin;D:\softs\nvm;D:\softs\nodejs
9 verbose lifecycle watch-dog@1.0.0~build: CWD: E:\dev\vue\watchDog-framework-web
10 silly lifecycle watch-dog@1.0.0~build: Args: [ '/d /s /c',
10 silly lifecycle 'webpack --progress --hide-modules --config build/webpack.prod.config.js' ]
11 silly lifecycle watch-dog@1.0.0~build: Returned: code: 2 signal: null
12 info lifecycle watch-dog@1.0.0~build: Failed to exec build script
13 verbose stack Error: watch-dog@1.0.0 build: `webpack --progress --hide-modules --config build/webpack.prod.config.js`
13 verbose stack Exit status 2
13 verbose stack at EventEmitter.<anonymous> (D:\softs\nvm\v8.11.1\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (D:\softs\nvm\v8.11.1\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid watch-dog@1.0.0
15 verbose cwd E:\dev\vue\watchDog-framework-web
16 verbose Windows_NT 10.0.14393
17 verbose argv "D:\\softs\\nodejs\\node.exe" "D:\\softs\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v8.11.1
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 2
22 error watch-dog@1.0.0 build: `webpack --progress --hide-modules --config build/webpack.prod.config.js`
22 error Exit status 2
23 error Failed at the watch-dog@1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]
ERROR in 1.2a66533fcf6762182963.chunk.js from UglifyJs
Unexpected token: name (dt) [1.2a66533fcf6762182963.chunk.js:3397,6]
ERROR in 3.2a66533fcf6762182963.chunk.js from UglifyJs
Unexpected token: name (dt) [3.2a66533fcf6762182963.chunk.js:3397,6]
Child html-webpack-plugin for "..\index.html":
1 asset
Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js?minimize!node_modules/autoprefixer-loader/index.js!node_modules/iview/dist/styles/iview.css:
Asset Size Chunks Chunk Names
2c2ae068be3b089e0a5b59abb1831550.eot 121 kB [emitted]
24712f6c47821394fba7942fbb52c3b2.ttf 189 kB [emitted]
05acfdb568b3df49ad31355b19495d4a.woff 67.9 kB [emitted]
621bd386841f74e0053cb8e67f8a0604.svg 334 kB [emitted] [big]
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! watch-dog@1.0.0 build: `webpack --progress --hide-modules --config build/webpack.prod.config.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the watch-dog@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-04-26T05_14_33_877Z-debug.log
求解決
踩了一天這個坑,終于跳出來了,根據(jù)自己的webpack.base.config.js所在的目錄,打包的時候相應(yīng)的include需要babel的路徑,路徑一定要正確,且include 和 exclude不能共用,或者說不能同時作用于同一個目錄吧。
按正常的邏輯。node_modules 里的文件應(yīng)該不包含es6的代碼才對
{
test: /\.js$/,
loader: 'happypack/loader?id=happybabel',
include: [resolve('../build'), resolve('../src'), resolve('../node_modules/iview/src'), resolve('../node_modules/iview/dist')]
}
北大青鳥APTECH成立于1999年。依托北京大學優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學院和江蘇省首批服務(wù)外包人才培訓基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團,成為集合面授教學培訓、網(wǎng)
達內(nèi)教育集團成立于2002年,是一家由留學海歸創(chuàng)辦的高端職業(yè)教育培訓機構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
曾工作于聯(lián)想擔任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍懿科技有限責任公司從事總經(jīng)理職務(wù)負責iOS教學及管理工作。
浪潮集團項目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術(shù)功底深厚。 授課風格 授課風格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。