Comments (16)
相对路径是支持的,你可以参考这个#4
放到CSS文件夹JS文件夹的这有个demo
stylePublicPath
用法和output.publicPath
的完全一样。只不过output.publicPath
默认是针对所有文件的,stylePublicPath
是准对css文件的。stylePublicPath
在AutoWebPlugin
的属性里配置,
下面这个例子分别把JS、CSS、IMG放到不同的CDN下,代码如下:
const CND = {
js: `//7.url.cn/edu/${name}/`,
css: `//8.url.cn/edu/${name}/`,
img: `//9.url.cn/edu/${name}/`
};
const autoPlugin = new AutoWebPlugin('./src/pages/', {
// 所有的css文件都放在8.url.cn
stylePublicPath: CND.css,
});
module.exports = {
entry: autoPlugin.entry({
vendor: './src/assets/vendor',
}),
output: {
path: path.resolve(__dirname, `public/cdn/${name}`),
publicPath: CND.js,
filename: '[name]_[chunkhash].js',
},
module: {
rules: [
{
test: /\.css$/,
// 提取出css
loaders: ExtractTextPlugin.extract({
// 通过css加载的文件都放在9.url.cn
publicPath: CND.img,
fallback: 'style-loader',
// 压缩css
use: ['css-loader?minimize'],
}),
},
{
test: /\.(gif|png|jpe?g|eot|woff|ttf|svg|pdf)$/,
loader: 'file-loader',
},
]
},
}
以上。希望能解决你的问题帮到你。有建议欢迎贡献,用的开心告诉你的朋友。
from web-webpack-plugin.
当然还有C.D等很多。
from web-webpack-plugin.
你看看这个两个demo
有没有和你相识的地方,如果没有你可以再把你的需求写详细点,我愿意为你写一个demo
from web-webpack-plugin.
谢谢,我仔细琢磨了,AutoWebPlugin 基本上能满足我的需求。
但是有个小BUG:
分离不出图片
此外:我还有个小要求。。
AutoWebPlugin 自动探测html入口 ,现在只能自动探测入口下的一级文件夹,能不能探测二级,三级。
from web-webpack-plugin.
要在HTML里加载本地文件,文件路径前要加./
用于区分这不是加载webpack里的chunk,代码如下
<img src="./local/path.png">
把所有页面都放在同一级是一个很好的习惯,因为这便于管理和维护,目录整齐规范。如果你非要这么干,你可以手动为每个页面写一个WebPlugin
from web-webpack-plugin.
<a href=""><img src="./img/math.png" alt="math"></a>
我拿你的代码测试过。。前面加了个A标签就不行了。
且如何把分离出的图片放到指定文件夹里去。
from web-webpack-plugin.
已经修复,请升级到 1.8.5 版本
from web-webpack-plugin.
还有个小问题,如何把分离出来的图片放到指定的文件夹里去?
from web-webpack-plugin.
目前只有通过webpack加载的图片可以指定输出目录,直接加载本地的还不支持。
from web-webpack-plugin.
...这样html 里的图片一多,生成后都放在dist根目录下。太乱了。。
from web-webpack-plugin.
我支持下加个配置属性
from web-webpack-plugin.
chunks: A1,A2,A3 共用一个A.js
chunks: B1,B2,B3 共用一个B.js
commonsChunk 该怎么写? 貌似不行(只能写一个)。。
from web-webpack-plugin.
这个你就不能使用AutoWebPlugin
提供的commonsChunk
选项了,因为AutoWebPlugin
提供的commonsChunk
选项只能是针对AutoWebPlugin
找到的所有页面提取公共代码。
如果你想要动态灵活的提取任何几个页面的代码,你需要直接额外的用CommonsChunkPlugin
去提取。其实AutoWebPlugin
的提取公共代码的实现就是使用CommonsChunkPlugin
。
AutoWebPlugin
会为它找到的每个页面生成一个名叫这个页面目录的chunk。你可以提前这些chunk的公共部分来提取任意页面的公共代码。
from web-webpack-plugin.
新增 配置属性 : 分离出html里的图片到指定目录 功能可以用了吗?
from web-webpack-plugin.
分离出html里的图片到指定目录 功能 , 不好操作的话。 能不能在源代码里面写死?代码在那个地方(我看了源代码好久都找不到。。)
from web-webpack-plugin.
大概在这里
https://github.com/gwuhaolin/web-webpack-plugin/blob/master/lib/Resource.js#L250
我最近有点忙,你要是等不急可以自己尝试着改下提merge。
from web-webpack-plugin.
Related Issues (20)
- index.html中如何添加挂载点id=app HOT 1
- 使用自定义filename输出html文件时,html内引入的资源路径出错
- html模版中使用_inline内联script时,让webpack loader处理文件内容? HOT 1
- AutoWebPlugin 的postEntrys属性 与 splitChunks 一起用时无效 HOT 1
- webpack4.6.0, 版本异常, 无法合并html HOT 1
- AutoWebPlugin 中没有 commonsChunk 选项? HOT 1
- JS 注入标签自定义 HOT 1
- JS 注入标签自定义
- 此处逻辑可能会引起<a href="/help.html">的标签被干掉 HOT 2
- 改动引起template配置失效 HOT 2
- Cannot read property 'data' of null 打包时报这个错误 HOT 2
- <script>是否添加crossorigin属性判断建议 HOT 1
- commonsChunk在webpack4.0失效了,无法提取打包公共代码
- async=""
- 有个多入口多出口的问题想请教一下 HOT 1
- 希望支持includePages属性 HOT 1
- Allow adding to current entry HOT 3
- TypeError: Cannot set property 'webPluginBeforeEmitHTML' of undefined HOT 1
- this code is not run when i configured in vue.config.js,it can cause template.html without complier HOT 1
- is there a way I can define a template without body,html tags?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web-webpack-plugin.