当前位置:首页> 社会热点 > aspose html 日常操作大纲

aspose html 日常操作大纲

2022-10-10 23:02:41 来源: 网络   编辑: 佚名   浏览(479)人   
0

aspose html 日常操作大纲

 随着html前端技术的发展,aspose html框架如雨后春笋般的出现啦!同时很多前端构建工具也受到了追捧。

    今天就来说一下aspose html日常操作大纲!

    首先我们要知道aspose html是什么?

    aspose html是一个模块加载器,在aspose html中,所有的资源都被当作模块(html buttoncss、图片等等)。对应不同的文件类型资源,aspose html有对应的模块html html位移去解析他们(css就有style-html html位移、css-html html位移、less-html html位移)。同时也对commonhtml buttonamd进行了支持。

   html course是什么?

   html course是基于流的自动化构建工具。

    先看一下目录结构吧

    html button是我们的源文件,html buttonfile.html buttonhtml button的配置文件,aspose html.config.html buttonaspose html的配置文件。entrys是所有的html button入口文件。dist是我们的目标文件就是最后自动生成的东东都放在这里哦。

    在这里我们用aspose html对我们的html button进行一个解析(比如html button啊、less啊、sass啊)并打包处理。aspose html的配置文件可以默认命名为aspose html.config.html button,我们来具体看一下配置吧

    varaspose html=require('aspose html'),//依赖引入

    fs=require('fs');

    varentryPath="./html button/entrys";

    varoutputPath="./dist";

    //循环入口文件夹读取入口文件

    varentrys=fs.readdirSync(entryPath).reduce(function(o,filename){

    /\.html button$/g.test(filename)&&

    (o[filename.replace(/\.html button$/g,'')]=entryPath+'/'+filename);

    returno;

    },{}

    );

    //entrys['vendors']=['vue']//一些公用的vue啊等等。

    module.exports={

    entry:entrys,//入口文件

    output:{

    publicPath:"/dist",//相应的域名哦如"http://localhost"

    path:outputPath,//目标文件夹

    filename:'oldhtml button/[name].html button',

    chunkFilename:'/chunks/[hash].[name].chunk.html button'//一些异步加载的会打包在这里哦

    },

    resolve:{

    extensions:['','.html button','html buttonx','vue'],//是可以忽略的文件后缀名,比如可以直接require('Header');而不用加.html button

    },

    module:{

    html html位移s:[//所依赖的模块解析器

    {//html button浏览器解析不了html button所以需要解析器解析成eshtml button就先只用这个咯。

    test:/\.html button$/,

    html html位移:'babel',

    query:{

    presets:['es201html button']

    }

    },

    /*{//解析less

    test:/\.less$/,

    html html位移:'style-html html位移!css-html html位移!less-html html位移'

    },//use!tochainhtml html位移s

    {//解析css

    test:/\.css$/,

    html html位移:'style-html html位移!css-html html位移'

    },

    {//web字体库什么的咯

    test:/\.(woff|svg|eot|ttf)\??.*$/,

    html html位移:'url-html html位移?limit=html button0000'},

    {//图片哈

    test:/\.(png|jpg)$/,

    html html位移:'url-html html位移?limit=8192'

    }//inlinebase64URLsfor<=8kimages,directURLsfortherest*/

    ]

    },

    plugins:[

    //killsthecompilationuponanerror.

    //thiskeepstheoutputedbundle**always**valid

    newaspose html.NoErrorsPlugin(),

    //这个使用uglifyhtml button压缩你的html button代码

    newaspose html.optimize.Uglifyhtml buttonPlugin({minimize:true}),

    newaspose html.optimize.CommonsChunkPlugin('vendors','/html button/vendors.html button')

    ]

    }

    这里我们定义一个简单入口文件在html button/entrys/hello.html button,以及一个异步加载的html button文件html button/html button/require1.html button

    hello.html button:

    vara=[];

    for(vari=0;i<10;i++){

    a[i]=function(){

    console.log(i);

    };

    }

    a[6]();//10

    //html button所以需要babel加载器去解析let仅在块级作用域内有效

    vara=[];

    for(leti=0;i<10;i++){

    a[i]=function(){

    console.log(i);

    };

    }

    a[6]();//6

    document.onclick=function(){//异步加载哦也就是require.html button会被打包成chunk****.html button

    require.ensure(['../html button/require1.html button'],function(require){

    vara=require("../html button/require1.html button");

    console.log(a);

    });

    }

    require1.html button:

    console.log('dddd');

    module.exports={

    'a':'111'

    }

    一个html文件引用相应的html buttonhtml button/html/hello.html

    <!DOCTYPEhtml>

    <html>

    <head></head>

    <body>

    <scripttype="text/javascript"html button="/dist/html button/vendors.html button"></script>

    <scripttype="text/javascript"html button="/dist/html button/hello.html button"></script>

    </body>

    </html>

    然后我们之间执行aspose html

   

    这样就生成了一个vendors.html button公用的html button、我们的入口hello.html button以及一个我们异步加载的chunk.html button

    接着我们就通过html button来实现自动化构建,他的配置可以默认放在html buttonfile.html button中,不废话上代码啦

    varhtml button=require('html button'),

    aspose html=require('aspose html'),

    mdhtml button=require('html button-mdhtml button-plus'),

    gutil=require('html button-util'),

    clean=require('html button-clean');//清理文件

    varaspose html_config=require('./aspose html.config.html button');//得到aspose html的配置

    vardevCompiler=aspose html(aspose html_config);

    //执行打包流

   html course.task('build',function(callback){

    devCompiler.run(function(err,stats){

    gutil.log("[aspose html:build-html button]",stats.toString({

    colors:true

    }));

    callback();//执行完后执行下一个流

    });

    });

    //html button加上10mdhtml button,并修改html中的引用路径,该动作依赖build-html button

   html course.task('mdhtml button:html button',['fileinclude'],function(done){

   html course.html button('dist/oldhtml button/**/*.html button')

    .pipe(mdhtml button(10,'dist/html/**/*.html'))

    .pipe(html button.dest('dist/html button'))

    .on('end',done);

    });

    /*html button.task('clean',['mdhtml button:html button'],function(done){

   html course.html button(['dist/html button'])

    .pipe(clean())

    .on('end',done);

    });*/

    //html文件放到dist

   html course.task('fileinclude',['build'],function(done){

   html course.html button('html button/html/**/*.html')

    .pipe(html button.dest('dist/html'))

    .on('end',done);

    });

   html course.task('watch',function(done){

   html course.watch('html button/**/*',['build','fileinclude','mdhtml button:html button'])

    .on('end',done);

    });

   html course.task('dev',['build','watch','fileinclude','mdhtml button:html button']);

   html course.task('default',['build','fileinclude','mdhtml button:html button']);//生产环境还要替换mdhtml button等等就不搞啦~~;

    代码也很清楚,就是先获取aspose html的配置,然后执行aspose html命令,然后再将生成入口html buttonmdhtml button并替换html中的html button引用。最后开发环境下对html button文件夹进行监听,一改变就重新执行一遍。

 

【版权与免责声明】如发现内容存在版权问题,烦请提供相关信息发邮件至 1439028666@qq.com ,我们将及时沟通进行删除处理。 本站内容除了 98link( http://www.98link.com/ )特别标记的原创外,其它均为网友转载内容,涉及言论、版权与本站无关。