Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
quantum-blocks-h5
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
quantum-blocks-h5
Commits
ae47e7cd
Commit
ae47e7cd
authored
Mar 31, 2021
by
郝聪敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: 区分测试和线上环境
parent
cea40be8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
62 deletions
+79
-62
upload-cos.js
upload-cos.js
+74
-0
webpack.config.js
webpack.config.js
+5
-62
No files found.
upload-cos.js
0 → 100644
View file @
ae47e7cd
const
COS
=
require
(
'
cos-nodejs-sdk-v5
'
);
const
path
=
require
(
'
path
'
);
const
fs
=
require
(
'
fs
'
);
const
prefix
=
process
.
env
.
NODE_ENV
===
'
production
'
?
'
qb
'
:
'
qb-test
'
;
const
cdnPrefix
=
`https://misc.lkbang.net/
${
prefix
}
/`
;
class
upload2Cos
{
filesPath
=
[];
instance
=
null
;
constructor
()
{
this
.
filesPath
=
[];
this
.
instance
=
new
COS
({
SecretId
:
'
AKIDVlxtVqOK9i0wc0m0e7C5saATZnl2xvUx
'
,
SecretKey
:
'
NWQ3VlmWeFtIQHrDI6F9oCheMq41lGVV
'
});
}
getFilesPath
()
{
this
.
_readFileList
(
path
.
resolve
(
__dirname
,
'
./public
'
),
this
.
filesPath
);
}
upload
()
{
this
.
getFilesPath
();
const
filesList
=
this
.
filesPath
.
map
(
filepath
=>
{
return
{
Bucket
:
'
misc-1258270469
'
,
Region
:
'
ap-beijing
'
,
Key
:
`
${
prefix
}${
filepath
.
split
(
'
quantum-blocks-h5
'
)[
1
]}
`
,
FilePath
:
filepath
}
});
this
.
instance
.
uploadFiles
({
files
:
filesList
,
SliceSize
:
1024
*
1024
,
onProgress
:
function
(
info
)
{
var
percent
=
parseInt
(
info
.
percent
*
10000
)
/
100
;
var
speed
=
parseInt
(
info
.
speed
/
1024
/
1024
*
100
)
/
100
;
console
.
log
(
'
进度:
'
+
percent
+
'
%; 速度:
'
+
speed
+
'
Mb/s;
'
);
},
onFileFinish
:
function
(
err
,
data
,
options
)
{
console
.
log
(
options
.
Key
+
'
上传
'
+
(
err
?
'
失败
'
:
'
完成
'
));
},
},
function
(
err
,
data
)
{
console
.
log
(
err
||
data
);
});
}
_isValid
(
path
)
{
const
format
=
[
'
.ico
'
,
'
.html
'
,
'
.ttf
'
,
'
.woff
'
,
'
.woff2
'
];
return
!
format
.
some
(
v
=>
path
.
endsWith
(
v
))
}
_readFileList
(
dir
,
filesPath
=
[])
{
const
files
=
fs
.
readdirSync
(
dir
);
files
.
forEach
((
item
,
index
)
=>
{
var
fullPath
=
path
.
join
(
dir
,
item
);
const
stat
=
fs
.
statSync
(
fullPath
);
if
(
stat
.
isDirectory
())
{
this
.
_readFileList
(
path
.
join
(
dir
,
item
),
filesPath
);
}
else
if
(
this
.
_isValid
(
fullPath
))
{
filesPath
.
push
(
fullPath
);
}
});
return
filesPath
;
}
}
module
.
exports
=
{
upload2Cos
,
cdnPrefix
};
\ No newline at end of file
webpack.config.js
View file @
ae47e7cd
'
use strict
'
;
'
use strict
'
;
const
path
=
require
(
'
path
'
);
const
path
=
require
(
'
path
'
);
const
fs
=
require
(
'
fs
'
);
const
SentryPlugin
=
require
(
"
webpack-sentry-plugin
"
);
const
SentryPlugin
=
require
(
"
webpack-sentry-plugin
"
);
const
resolve
=
filepath
=>
path
.
resolve
(
__dirname
,
filepath
);
const
resolve
=
filepath
=>
path
.
resolve
(
__dirname
,
filepath
);
const
SentryConfig
=
require
(
"
./app/web/.sentryclirc.ts
"
);
const
SentryConfig
=
require
(
"
./app/web/.sentryclirc.ts
"
);
const
{
upload2Cos
,
cdnPrefix
}
=
require
(
"
./upload-cos.js
"
);
module
.
exports
=
{
module
.
exports
=
{
entry
:
{
entry
:
{
// 'login': 'app/web/page/login/index.vue',
// 'editor': 'app/web/page/editor/index.ts',
'
activity
'
:
'
app/web/page/activity/index.ts
'
,
'
activity
'
:
'
app/web/page/activity/index.ts
'
,
},
},
resolve
:
{
resolve
:
{
...
@@ -20,10 +16,7 @@ module.exports = {
...
@@ -20,10 +16,7 @@ module.exports = {
'
@asset
'
:
resolve
(
'
app/web/asset
'
),
'
@asset
'
:
resolve
(
'
app/web/asset
'
),
'
@framework
'
:
resolve
(
'
app/web/framework
'
),
'
@framework
'
:
resolve
(
'
app/web/framework
'
),
'
@component
'
:
resolve
(
'
app/web/component
'
),
'
@component
'
:
resolve
(
'
app/web/component
'
),
'
@store
'
:
resolve
(
'
app/web/page/store
'
),
'
@store
'
:
resolve
(
'
app/web/page/store
'
)
// '@router': resolve('app/web/page/admin/home/router'),
// '@view': resolve('app/web/page/admin/home/view'),
// '@editor': resolve('app/web/page/editor')
}
}
},
},
nodeExternals
:
{
nodeExternals
:
{
...
@@ -162,66 +155,16 @@ module.exports = {
...
@@ -162,66 +155,16 @@ module.exports = {
}
}
},
},
externals
:
{
externals
:
{
// 'vue': 'Vue',
// 'vue-router': 'VueRouter',
// 'vuex': 'Vuex',
'
axios
'
:
'
axios
'
,
'
axios
'
:
'
axios
'
,
'
sa-sdk-javascript
'
:
'
sensorsDataAnalytic201505
'
,
'
sa-sdk-javascript
'
:
'
sensorsDataAnalytic201505
'
,
'
swiper
'
:
'
Swiper
'
,
'
swiper
'
:
'
Swiper
'
,
},
},
// mode: 'development',
// mode: 'development',
devtool
:
'
source-map
'
,
devtool
:
'
source-map
'
,
cdn
:
'
https://misc.lkbang.net/qb/
'
,
cdn
:
cdnPrefix
,
done
(){
done
(){
const
COS
=
require
(
'
cos-nodejs-sdk-v5
'
);
const
instance
=
new
upload2Cos
();
const
cos
=
new
COS
({
instance
.
upload
();
SecretId
:
'
AKIDVlxtVqOK9i0wc0m0e7C5saATZnl2xvUx
'
,
SecretKey
:
'
NWQ3VlmWeFtIQHrDI6F9oCheMq41lGVV
'
});
const
filesPath
=
[];
function
isValid
(
path
)
{
const
format
=
[
'
.ico
'
,
'
.html
'
,
'
.ttf
'
,
'
.woff
'
,
'
.woff2
'
];
return
!
format
.
some
(
v
=>
path
.
endsWith
(
v
))
}
function
readFileList
(
dir
,
filesPath
=
[])
{
const
files
=
fs
.
readdirSync
(
dir
);
files
.
forEach
((
item
,
index
)
=>
{
var
fullPath
=
path
.
join
(
dir
,
item
);
const
stat
=
fs
.
statSync
(
fullPath
);
if
(
stat
.
isDirectory
())
{
readFileList
(
path
.
join
(
dir
,
item
),
filesPath
);
//递归读取文件
}
else
if
(
isValid
(
fullPath
))
{
filesPath
.
push
(
fullPath
);
}
});
return
filesPath
;
}
readFileList
(
path
.
resolve
(
__dirname
,
'
./public
'
),
filesPath
);
const
filesList
=
filesPath
.
map
(
filepath
=>
{
const
publicPath
=
filepath
.
split
(
'
public
'
)[
1
];
const
Key
=
`qb/public
${
publicPath
}
`
;
console
.
log
(
'
filepath
'
,
filepath
,
Key
);
return
{
Bucket
:
'
misc-1258270469
'
,
Region
:
'
ap-beijing
'
,
Key
,
FilePath
:
filepath
}
});
cos
.
uploadFiles
({
files
:
filesList
,
SliceSize
:
1024
*
1024
,
onProgress
:
function
(
info
)
{
var
percent
=
parseInt
(
info
.
percent
*
10000
)
/
100
;
var
speed
=
parseInt
(
info
.
speed
/
1024
/
1024
*
100
)
/
100
;
console
.
log
(
'
进度:
'
+
percent
+
'
%; 速度:
'
+
speed
+
'
Mb/s;
'
);
},
onFileFinish
:
function
(
err
,
data
,
options
)
{
console
.
log
(
options
.
Key
+
'
上传
'
+
(
err
?
'
失败
'
:
'
完成
'
));
},
},
function
(
err
,
data
)
{
console
.
log
(
err
||
data
);
});
},
},
customize
(
webpackConfig
){
customize
(
webpackConfig
){
// 此外 webpackConfig 为原生生成的 webpack config,可以进行自定义处理
// 此外 webpackConfig 为原生生成的 webpack config,可以进行自定义处理
...
...
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