UNPKG

1.19 kBJavaScriptView Raw
1/**
2 * 获取文件输出路径
3 *
4 * @param {any} src
5 * @param {any} isDebug
6 * @returns
7 *
8 * @memberOf Watch
9 */
10module.exports = (src,isDebug)=>{
11 const {path} = {
12 path:require('path')
13 };
14
15 let correspondence = {
16 '.pug':'.html',
17 '.html':'.html',
18 '.htm':'.htm',
19 '.scss':fws.config.projectType === 'wxapp' ? '.wxss':'.css',
20 '.ts':'.js',
21 '.tsx':'.js',
22 '.jsx':'.js',
23 '.es':'.js',
24 '.es6':'.js'
25 },
26 //fileType = path.extname(src).toLowerCase(),
27 fileType = path.extname(src),
28 fileName = path.basename(src,fileType),
29
30 //输出文件扩展名,如果上面的对应关系中有指定从对应关系中取,否则为原始扩展名
31 outExtName = correspondence[fileType] === undefined ? fileType : correspondence[fileType],
32 dist = '';
33
34 if(isDebug){
35 dist = path.join(path.dirname(src.replace(fws.srcPath,fws.devPath)),fileName + outExtName);
36 }else{
37 dist = path.join(path.dirname(src.replace(fws.srcPath,fws.distPath)),fileName + outExtName);
38 };
39
40 return dist;
41
42};