切换导航条
切换导航条
当前项目
正在载入...
登录
术习电报
/
electron-vue-template
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
作者
umbrella22
2020-09-12 17:00:49 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
提交
03525139e136051f6a6f8a7cbf5a3b7d787aed05
03525139
1 个父辈
2fdd8c9a
剔除冗余代码
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
4 行增加
和
278 行删除
.electron-vue/build.js
.electron-vue/dev-runner.js
.electron-vue/webpack.main.config.js
.electron-vue/webpack.web.config.js
.electron-vue/build.js
查看文件 @
0352513
...
...
@@ -11,7 +11,6 @@ const Multispinner = require('multispinner')
const
mainConfig
=
require
(
'./webpack.main.config'
)
const
rendererConfig
=
require
(
'./webpack.renderer.config'
)
const
webConfig
=
require
(
'./webpack.web.config'
)
const
doneLog
=
chalk
.
bgGreen
.
white
(
' DONE '
)
+
' '
const
errorLog
=
chalk
.
bgRed
.
white
(
' ERROR '
)
+
' '
...
...
@@ -99,8 +98,8 @@ function pack (config) {
function
web
()
{
del
.
sync
([
'dist/web/*'
,
'!.gitkeep'
])
web
Config
.
mode
=
'production'
webpack
(
web
Config
,
(
err
,
stats
)
=>
{
renderer
Config
.
mode
=
'production'
webpack
(
renderer
Config
,
(
err
,
stats
)
=>
{
if
(
err
||
stats
.
hasErrors
())
console
.
log
(
err
)
console
.
log
(
stats
.
toString
({
...
...
.electron-vue/dev-runner.js
查看文件 @
0352513
'use strict'
process
.
env
.
NODE_ENV
=
'development'
const
chalk
=
require
(
'chalk'
)
const
electron
=
require
(
'electron'
)
const
path
=
require
(
'path'
)
...
...
.electron-vue/webpack.main.config.js
查看文件 @
0352513
...
...
@@ -8,10 +8,6 @@ const webpack = require('webpack')
const
MinifyPlugin
=
require
(
"babel-minify-webpack-plugin"
);
const
config
=
require
(
'../config'
)
// const os = require('os')
// const HappyPack = require('happypack')
// const HappyThreadPool = HappyPack.ThreadPool({ size: os.cpus().length > 4 ? 4 : os.cpus().length })
function
resolve
(
dir
)
{
return
path
.
join
(
__dirname
,
'..'
,
dir
)
}
...
...
@@ -43,7 +39,7 @@ let mainConfig = {
// },
{
test
:
/
\.
ts$/
,
use
:
[{
use
:
[
'thread-loader'
,
{
loader
:
'babel-loader'
,
options
:
{
cacheDirectory
:
true
...
...
@@ -68,16 +64,6 @@ let mainConfig = {
},
plugins
:
[
new
webpack
.
NoEmitOnErrorsPlugin
(),
// new HappyPack({
// id: "MainHappyBabel",
// loaders: [{
// loader: 'babel-loader',
// options: {
// cacheDirectory: true
// }
// }],
// threadPool: HappyThreadPool
// })
],
resolve
:
{
alias
:
{
...
...
.electron-vue/webpack.web.config.js
deleted
100644 → 0
查看文件 @
2fdd8c9
'use strict'
process
.
env
.
BABEL_ENV
=
'web'
const
os
=
require
(
'os'
)
const
path
=
require
(
'path'
)
const
webpack
=
require
(
'webpack'
)
const
MinifyPlugin
=
require
(
"babel-minify-webpack-plugin"
);
const
CopyWebpackPlugin
=
require
(
'copy-webpack-plugin'
)
const
MiniCssExtractPlugin
=
require
(
'mini-css-extract-plugin'
)
const
HtmlWebpackPlugin
=
require
(
'html-webpack-plugin'
)
const
TerserPlugin
=
require
(
'terser-webpack-plugin'
);
const
{
VueLoaderPlugin
}
=
require
(
'vue-loader'
)
const
HappyPack
=
require
(
'happypack'
)
const
HappyThreadPool
=
HappyPack
.
ThreadPool
({
size
:
os
.
cpus
().
length
>
4
?
4
:
os
.
cpus
().
length
})
function
resolve
(
dir
)
{
return
path
.
join
(
__dirname
,
'..'
,
dir
)
}
let
webConfig
=
{
devtool
:
'#cheap-module-eval-source-map'
,
entry
:
{
web
:
resolve
(
'src/renderer/main.js'
)
},
module
:
{
rules
:
[
// {
// test: /\.(js|vue)$/,
// enforce: 'pre',
// exclude: /node_modules/,
// use: {
// loader: 'eslint-loader',
// options: {
// formatter: require('eslint-friendly-formatter')
// }
// }
// },
{
test
:
/
\.
scss$/
,
use
:
[
'vue-style-loader'
,
{
loader
:
'css-loader'
,
options
:
{
esModule
:
false
}
},
'sass-loader'
]
},
{
test
:
/
\.
sass$/
,
use
:
[
'vue-style-loader'
,
{
loader
:
'css-loader'
,
options
:
{
esModule
:
false
}
},
'sass-loader?indentedSyntax'
]
},
{
test
:
/
\.
less$/
,
use
:
[
'vue-style-loader'
,
{
loader
:
'css-loader'
,
options
:
{
esModule
:
false
}
},
'less-loader'
]
},
{
test
:
/
\.
css$/
,
use
:
[
'vue-style-loader'
,
{
loader
:
'css-loader'
,
options
:
{
esModule
:
false
}
}]
},
{
test
:
/
\.
html$/
,
use
:
'vue-html-loader'
},
{
test
:
/
\.
js$/
,
use
:
'happypack/loader?id=HappyRendererBabel'
,
include
:
[
resolve
(
'src/renderer'
)],
exclude
:
/node_modules/
},
{
test
:
/
\.
vue$/
,
use
:
{
loader
:
'vue-loader'
,
options
:
{
loader
:
'vue-loader'
,
options
:
{
cacheDirectory
:
'node_modules/.cache/vue-loader'
,
cacheIdentifier
:
'7270960a'
,
}
}
}
},
{
test
:
/
\.
svg$/
,
loader
:
'svg-sprite-loader'
,
include
:
[
resolve
(
'src/renderer/icons'
)],
options
:
{
symbolId
:
'icon-[name]'
}
},
{
test
:
/
\.(
png|jpe
?
g|gif|svg
)(\?
.*
)?
$/
,
exclude
:
[
resolve
(
'src/renderer/icons'
)],
use
:
{
loader
:
'url-loader'
,
query
:
{
esModule
:
false
,
limit
:
10000
,
name
:
'imgs/[name].[ext]'
}
},
},
{
test
:
/
\.(
woff2
?
|eot|ttf|otf
)(\?
.*
)?
$/
,
use
:
{
loader
:
'url-loader'
,
query
:
{
esModule
:
false
,
limit
:
10000
,
name
:
'fonts/[name].[ext]'
}
}
}
]
},
plugins
:
[
new
VueLoaderPlugin
(),
new
MiniCssExtractPlugin
({
filename
:
'styles.css'
}),
new
HtmlWebpackPlugin
({
filename
:
'index.html'
,
template
:
path
.
resolve
(
__dirname
,
'../src/index.ejs'
),
minify
:
{
collapseWhitespace
:
true
,
removeAttributeQuotes
:
true
,
removeComments
:
true
},
nodeModules
:
false
}),
new
webpack
.
DefinePlugin
({
'process.env.IS_WEB'
:
'true'
}),
new
webpack
.
HotModuleReplacementPlugin
(),
new
webpack
.
NoEmitOnErrorsPlugin
(),
new
HappyPack
({
id
:
'HappyRendererBabel'
,
loaders
:
[{
loader
:
'babel-loader'
,
options
:
{
cacheDirectory
:
true
}
}],
threadPool
:
HappyThreadPool
}),
],
output
:
{
filename
:
'[name].js'
,
path
:
path
.
join
(
__dirname
,
'../dist/web'
)
},
resolve
:
{
alias
:
{
'@'
:
path
.
join
(
__dirname
,
'../src/renderer'
),
'vue$'
:
'vue/dist/vue.esm.js'
},
extensions
:
[
'.js'
,
'.vue'
,
'.json'
,
'.css'
]
},
target
:
'web'
}
/**
* Adjust webConfig for production settings
*/
if
(
process
.
env
.
NODE_ENV
===
'production'
)
{
webConfig
.
devtool
=
''
webConfig
.
plugins
.
push
(
new
MinifyPlugin
(),
new
CopyWebpackPlugin
({
patterns
:
[
{
from
:
path
.
join
(
__dirname
,
'../static'
),
to
:
path
.
join
(
__dirname
,
'../dist/electron/static'
),
globOptions
:
{
ignore
:
[
'.*'
]
}
}
]
}),
new
webpack
.
DefinePlugin
({
'process.env.NODE_ENV'
:
'"production"'
}),
new
webpack
.
LoaderOptionsPlugin
({
minimize
:
true
})
)
webConfig
.
optimization
=
{
splitChunks
:
{
chunks
:
"async"
,
cacheGroups
:
{
vendor
:
{
// 将第三方模块提取出来
minSize
:
30000
,
minChunks
:
1
,
test
:
/node_modules/
,
chunks
:
'initial'
,
name
:
'vendor'
,
priority
:
1
},
commons
:
{
test
:
/
[\\/]
src
[\\/]
common
[\\/]
/
,
name
:
'commons'
,
minSize
:
30000
,
minChunks
:
3
,
chunks
:
'initial'
,
priority
:
-
1
,
reuseExistingChunk
:
true
// 这个配置允许我们使用已经存在的代码块
}
}
},
runtimeChunk
:
{
name
:
'runtime'
},
minimizer
:
[
new
TerserPlugin
({
test
:
/
\.
js
(\?
.*
)?
$/i
,
extractComments
:
false
,
cache
:
false
,
sourceMap
:
false
,
terserOptions
:
{
warnings
:
false
,
compress
:
{
hoist_funs
:
false
,
hoist_props
:
false
,
hoist_vars
:
false
,
inline
:
false
,
loops
:
false
,
dead_code
:
true
,
booleans
:
true
,
if_return
:
true
,
warnings
:
false
,
drop_console
:
true
,
drop_debugger
:
true
,
pure_funcs
:
[
'console.log'
]
},
output
:
{
comments
:
false
,
},
}
})]
}
}
module
.
exports
=
webConfig
请
注册
或
登录
后发表评论