• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

index.html

!声明文档类型

html lang='en '

meta charset='UTF-8 '

meta name=' viewport ' content=' width=device-width,initial-scale=1.0 '

titlewebpack/title

/头

身体

氕你好延迟加载/h1

按钮id='btn '按钮/按钮

/body

/html

索引。射流研究…

console.log('index.js文件被加载了~');

//从""导入{ mul } ./test ';

document.getElementById('btn ').onclick=function() {

//懒加载~:当文件需要使用时才加载~

//预加载预取:会在使用之前,提前加载射流研究…文件

//正常加载可以认为是并行加载(同一时间加载多个文件)

//预加载预取:等其他资源加载完毕,浏览器空闲了,再偷偷加载资源

import(/* webpackchunkname : ' test ',webpackprefeetch : true */' ./test’).然后(({ mul })={

console.log(mul(4,5));

});

};

测试。射流研究…

console.log('test.js文件被加载了~');

导出函数mul(x,y) {

返回x * y;

}

导出函数计数(x,y) {

返回x-y;

}

网络包。配置。射流研究…

const { resolve }=require(' path ');

const HtmlWebpackPlugin=require(' html-web pack-plugin ');

模块。导出={

//单入口

条目:/src/js/index.js ',

输出: {

filename : ' js/[name]. js,

path: resolve(__dirname,“build”)

},

插件: [

新建HtmlWebpackPlugin({

模板: '。/src/index.html ',

minify: {

折叠空白:真,

removeComments: true

}

})

],

优化: {

splitChunks: {

chunks: '全部'

}

},

型号: '生产'

};

Link to comment
Share on other sites