Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
檀越@新空间
Coding Tree
提交
859a3121
C
Coding Tree
项目概览
檀越@新空间
/
Coding Tree
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coding Tree
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
859a3121
编写于
6月 01, 2022
作者:
彭世瑜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
b6e701c9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
181 addition
and
5 deletion
+181
-5
blog/php-mysql/index.md
blog/php-mysql/index.md
+2
-2
blog/php-mysql/sql-join.md
blog/php-mysql/sql-join.md
+1
-1
blog/webpack/webpack-loader.md
blog/webpack/webpack-loader.md
+177
-1
package.json
package.json
+1
-1
未找到文件。
blog/php-mysql/index.md
浏览文件 @
859a3121
...
...
@@ -40,9 +40,9 @@
19.
[
查询中的运算符
](
blog/php-mysql/sql-operator.md
)
[
联合查询 union
](
blog/php-mysql/sql-union.md
)
20.
[
联合查询 union
](
blog/php-mysql/sql-union.md
)
[
连接查询 join
](
blog/php-mysql/sql-join.md
)
21.
[
连接查询 join
](
blog/php-mysql/sql-join.md
)
[
子查询 sub query
](
blog/php-mysql/sql-subquery.md
)
...
...
blog/php-mysql/sql-join.md
浏览文件 @
859a3121
# 连接查询
# 连接查询
join
将多张表连到一起查询 导致记录行数和字段列发生变化
...
...
blog/webpack/webpack-loader.md
浏览文件 @
859a3121
...
...
@@ -447,5 +447,181 @@ module.exports = {
```
### file-loader
https://www.bilibili.com/video/BV14T4y1z7sw?p=74&spm_id_from=pageDriver
使用webpack提供的loader工具
```
$ pnpm i -D loader-utils
```
```
js
// file-loader.js
// https://github.com/webpack/loader-utils
const
loaderUtils
=
require
(
"
loader-utils
"
);
module
.
exports
=
function
(
content
)
{
// 1、根据文件内容生成带hash的文件名
const
interpolatedName
=
loaderUtils
.
interpolateName
(
this
,
"
[hash].[ext][query]
"
,
{
content
}
);
// 2、将文件输出
this
.
emitFile
(
interpolatedName
,
content
)
// 3、返回文件名
return
`module.exports = "
${
interpolatedName
}
"`
;
};
// raw loader 处理图片资源,content输入为Buffer类型
module
.
exports
.
raw
=
true
;
```
使用
```
js
// src/index.js
import
'
./style.css
'
;
```
```
css
/* style.css */
.box
{
width
:
200px
;
height
:
200px
;
/* css 文件中使用图片资源 */
background-image
:
url("./girl.png")
;
}
```
```
js
// webpack.config.js
module
.
exports
=
{
module
:
{
rules
:
[
// 处理图片资源
{
test
:
/
\.(
png|jpe
?
g|gif
)
$/
,
loader
:
"
./loaders/file-loader/index.js
"
,
// 不使用 asset 模块处理,避免生成重复资源
type
:
'
javascript/auto
'
},
// 处理css资源
{
test
:
/
\.
css$/
,
use
:
[
'
style-loader
'
,
'
css-loader
'
,
]
},
],
},
};
```
css代码替换如下
```
css
.box
{
width
:
200px
;
height
:
200px
;
background-image
:
url(/39e33252eac24cf9.png)
;
}
```
### style-loader
在file-loader 的基础上继续
定义loader, 将css插入到body中
```
js
// style-loader.js
module
.
exports
=
function
()
{};
module
.
exports
.
pitch
=
function
(
remainingRequest
)
{
// remainingRequest 剩余的还要处理的loader
// console.log(remainingRequest);
// _modules/css-loader/dist/cjs.js!/root/webpack-loader/src/style.css
// 将绝对路径转换为相对路径
const
relativePath
=
remainingRequest
.
split
(
"
!
"
)
.
map
((
absolutePath
)
=>
{
return
this
.
utils
.
contextify
(
this
.
context
,
absolutePath
);
})
.
join
(
"
!
"
);
console
.
log
(
relativePath
);
// 引入css-loader处理后的资源
// 创建style标签,将内容插入到页面中
const
script
=
`
import style from '!!
${
relativePath
}
';
const styleElement = document.createElement('style');
styleElement.innerHTML = style;
document.head.appendChild(styleElement);
`
;
// 终止后面的loader执行
return
script
;
};
```
使用
```
js
// webpack.config.js
const
path
=
require
(
"
path
"
);
const
HtmlWebpackPlugin
=
require
(
'
html-webpack-plugin
'
);
module
.
exports
=
{
entry
:
"
./src/index.js
"
,
output
:
{
path
:
path
.
resolve
(
__dirname
,
"
dist
"
),
filename
:
"
bundle.js
"
,
clean
:
true
,
},
module
:
{
rules
:
[
{
test
:
/
\.(
png|jpe
?
g|gif
)
$/
,
loader
:
"
./loaders/file-loader/index.js
"
,
// 不使用 asset 模块处理,避免生成重复资源
type
:
'
javascript/auto
'
},
{
test
:
/
\.
css$/
,
use
:
[
'
./loaders/style-loader/index.js
'
,
'
css-loader
'
,
]
},
],
},
plugins
:
[
new
HtmlWebpackPlugin
({
template
:
'
./src/index.html
'
,
}),
],
mode
:
"
development
"
,
};
```
https://www.bilibili.com/video/BV14T4y1z7sw?p=77&spm_id_from=pageDriver
\ No newline at end of file
package.json
浏览文件 @
859a3121
...
...
@@ -7,7 +7,7 @@
"scripts"
:
{
"dev"
:
"~/.nvm/versions/node/v12.22.6/bin/docsify serve --open ./"
,
"live"
:
"live-server"
,
"start"
:
"http-server -o /"
"start"
:
"http-server -o /
-c-1
"
},
"repository"
:
{
"type"
:
"git"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录