Skip to content

Commit

Permalink
fix: font files should be compiled via file-loader, Close #4047
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Mar 4, 2020
1 parent 243301c commit 7cbcc63
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/bundler-webpack/src/fixtures/font/a.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@font-face {
font-family: 'foo';
src: url("./a.eot?v=2.4.0");
}
1 change: 1 addition & 0 deletions packages/bundler-webpack/src/fixtures/font/a.eot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eoteot
6 changes: 6 additions & 0 deletions packages/bundler-webpack/src/fixtures/font/expect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { IExpectOpts } from '../types';

export default ({ indexCSS }: IExpectOpts) => {
expect(indexCSS).toContain(`src: url(./static/a.`);
expect(indexCSS).toContain(`.eot);`);
}
1 change: 1 addition & 0 deletions packages/bundler-webpack/src/fixtures/font/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './a.css';
14 changes: 11 additions & 3 deletions packages/bundler-webpack/src/getConfig/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,17 @@ export default async function getConfig(
esModule: false,
});

// prettier-ignore
webpackConfig.module
.rule('fonts')
.test(/\.(eot|woff|woff2|ttf)(\?.*)?$/)
.use('file-loader')
.loader(require.resolve('file-loader'))
.options({
name: 'static/[name].[hash:8].[ext]',
esModule: false,
});

// css
css({
config,
Expand Down Expand Up @@ -265,9 +276,6 @@ export default async function getConfig(
// },
// ]);

// copy
// TODO

// define
webpackConfig.plugin('define').use(bundleImplementor.DefinePlugin, [
{
Expand Down

0 comments on commit 7cbcc63

Please sign in to comment.