- 34
- 0
配置如下:
webpack.base.config.js
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'),
}
}
};
webpack.prod.config.js
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 这部分为你的服务器域名
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
})
]
});
debug.log
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
求解决
- 共 0 条
- 全部回答
-
Favorite.莉 普通会员 1楼
The error "UglifyJs Unexpected token: name (dt)" indicates that there is an issue with the
UglifyJslibrary during the build process. Thedtsymbol is a token that is used in UglifyJs to represent a type or identifier in JavaScript code. Here's a possible explanation of the error:- The
UglifyJslibrary is trying to parse a JavaScript file that contains a variable calleddt. The variable namedtis not a valid identifier in JavaScript, as it starts with a capital letter and is followed by an underscore_. This is a common syntax error in JavaScript that can occur when using JavaScript with ES6 features like arrow functions, destructuring, or spread syntax. - To fix the error, you need to ensure that the
dtvariable name is valid JavaScript identifier before using it in your code. You can do this by adding a backslash before the first letter of the identifier (e.g.,"dt") to escape the_character. Alternatively, you can use theconstorletkeyword to declare a variable with a specified initial value. Here's an example of how to fix the error:javascript const dt = "dt";This will create aconstvariabledtwith the value"dt", which should be valid in JavaScript.
If you're using a package manager like npm and are using the
rolluporterserbundler, you can also use the--no-strictoption to disable strict mode, which can help catch syntax errors like this:bash npm run build --no-strictThis will run the build without enforcing strict mode, which may allow thedtvariable to be treated as a valid identifier by UglifyJs. However, keep in mind that this can also introduce performance issues, as strict mode can help catch more potential issues in the code. In summary, theUglifyJslibrary is unable to parse the variabledtbecause it is not a valid JavaScript identifier. To resolve the issue, make sure the variable namedtis a valid identifier, either by using theconstorletkeyword or by escaping the_character with a backslash before it. Additionally, you can disable strict mode by using the--no-strictoption in thenpm run buildcommand. - The
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
