猿问

webpack的exract-text-webpack-plugin插件的疑问

刚学习webpack,请问注释行的代码是什么意思,查了官方文档没看明白。

官方实例:

Multiple Instances There is also an extract function on the instance.
You should use this if you have more than one instance of ExtractTextPlugin.

https://img2.mukewang.com/5c3d9cd50001727204900307.jpg

这是官方对extract方法的参数说明:

extract

ExtractTextPlugin.extract(options: loader | object)
Creates an extracting loader from an existing loader. Supports loaders of type { loader: [name]-loader -> {String}, options: {} -> {Object} }.

  1. options.use 
    Loader(s) that should be used for converting the resource to a CSS exporting module (required)

  2. options.fallback 
    loader(e.g 'style-loader') that should be used when the CSS is not extracted (i.e. in an additional chunk when allChunks: false)

  3. options.publicPath
    Override the publicPath setting for this loader


月关宝盒
浏览 452回答 1
1回答

隔江千里

你这是webpack1.x吧? 首先webpack在页面中引用某css比如require("a.css"); 如果没有配置项的话是css in js形式,如果配置了style-loader是可以把css文件提取到style标签里边然后添加到head标签内的,如果在此之上配置了ExtractTextPlugin插件,就可以把这样式提取到文件中,不知道LZ了解了吗,毕竟单纯的理论有些晦涩(less sass等同理,只是多了一些配置)?
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答