Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
activity-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liupengfei
activity-core
Commits
795b6e9d
Commit
795b6e9d
authored
Jul 14, 2020
by
liupengfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
开发环境搭建
parent
8f00741f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
+19
-11
build-entry.js
cli/build-entry.js
+18
-10
build.js
cli/build.js
+1
-1
No files found.
cli/build-entry.js
View file @
795b6e9d
/*
* @Author: flyharvest
* @Date: 2020-07-14 10:15:41
* @LastEditTime: 2020-07-14 1
0:43:0
4
* @LastEditTime: 2020-07-14 1
2:11:3
4
* @LastEditors: flyharvest
*/
const
fs
=
require
(
'fs'
)
const
path
=
require
(
'path'
)
const
chalk
=
require
(
'chalk'
)
function
error
(
message
)
{
return
new
Error
({
message
})
}
function
commandArgs
(
string
)
{
return
process
.
env
[
string
]
}
...
...
@@ -17,7 +23,7 @@ function access (path) {
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
access
(
path
,
(
err
)
=>
{
if
(
err
)
{
reject
(
`没有找到对应文件
${
path
}
`
)
reject
(
error
(
`没有找到对应文件
${
path
}
`
)
)
}
else
{
resolve
(
true
)
}
...
...
@@ -30,7 +36,7 @@ function writeFile (path, content) {
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
writeFile
(
path
,
content
,
{
encoding
:
'utf8'
},
(
err
)
=>
{
if
(
err
)
{
reject
(
`写入文件失败
${
path
}
`
)
reject
(
error
(
`写入文件失败
${
path
}
`
)
)
}
else
{
resolve
(
content
)
}
...
...
@@ -62,9 +68,10 @@ const env = process.env.NODE_ENV
const
autoWriteFileName
=
`
${
env
}
scripts`
// 获取入口文件
async
function
getEntry
()
{
async
function
getEntry
()
{
if
(
!
lib
)
{
return
Promise
.
reject
(
`开发模式下,必须指定包名 \n lib = xxx yarn serve`
)
const
message
=
'开发模式下,必须指定包名
\
n lib = xxx yarn serve'
return
Promise
.
reject
(
error
(
message
))
}
else
{
const
devPath
=
path
.
resolve
(
__dirname
,
'../test'
,
lib
,
'./index.js'
)
let
devHtml
=
path
.
resolve
(
__dirname
,
'../test'
,
lib
,
'./index.html'
)
...
...
@@ -74,9 +81,9 @@ async function getEntry() {
devHtml
=
path
.
resolve
(
__dirname
,
'../test/public/index.html'
)
}
if
(
has
[
0
]
===
false
)
{
return
Promise
.
reject
(
`dev 下未找到
${
lib
}
/index.js`
)
return
Promise
.
reject
(
error
(
`test 下未找到
${
lib
}
/index.js`
)
)
}
else
if
(
has
[
2
]
===
false
)
{
return
Promise
.
reject
(
`src 下未找到
${
lib
}
/index.js`
)
return
Promise
.
reject
(
error
(
`src 下未找到
${
lib
}
/index.js`
)
)
}
return
[
devPath
,
devHtml
]
}
...
...
@@ -108,8 +115,9 @@ function buildEntry () {
.
then
(()
=>
{
buildInStep
(
'入口文件构建完成, 开始 rollup 构建'
)
})
.
catch
(
err
=>
{
buildError
(
err
)
.
catch
(
err
=>
{
const
{
message
=
'未知错误'
}
=
err
buildError
(
message
)
})
}
...
...
cli/build.js
View file @
795b6e9d
/*
* @Author: flyharvest
* @Date: 2020-07-08 17:22:20
* @LastEditTime: 2020-07-14 1
1:56:05
* @LastEditTime: 2020-07-14 1
2:30:10
* @LastEditors: flyharvest
*/
const
{
dotenv
}
=
require
(
'./util'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment