Skip to content

Commit

Permalink
feat: url-loader\file-loader处理图片\字体
Browse files Browse the repository at this point in the history
  • Loading branch information
m-alfred committed Oct 20, 2020
1 parent 404e72d commit 1ba4215
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
22 changes: 22 additions & 0 deletions config/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ module.exports = {
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.(svg|png|jpe?g|gif|mp3|mp4)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
},
},
],
},
{
test: /\.(woff2?|eot|ttf|otf)$/i,
use: [
{
loader: 'file-loader',
options: {
limit: 8192,
},
},
],
},
]
},
plugins: [
Expand Down
Binary file added src/assets/pikachu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions src/containers/home/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React, { Component } from 'react'
import { isValid } from '@/utils';
import { Button } from 'antd';
import picPikachu from '@/assets/pikachu.jpg';
// import './index.less';

class Home extends Component{
constructor(props) {
super(props)
Expand All @@ -10,12 +14,15 @@ class Home extends Component{
}
render() {
return(
<div >
home
<div className='the-home'>
<h3>home</h3>
{
'isValid:' + isValid(1)
}
<button onClick={() => this.props.history.push({pathname: '/detail'})}>to detail</button>
<div >
<Button onClick={() => this.props.history.push({pathname: '/detail'})}>to detail</Button>
</div>
<img src={picPikachu} alt=""/>
</div>
)
}
Expand Down
3 changes: 3 additions & 0 deletions src/containers/home/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.the-home {
background-color: #ccc;
}

0 comments on commit 1ba4215

Please sign in to comment.