-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: missing auxiliary assets (#662)
- Loading branch information
1 parent
fed2dea
commit f28c1e1
Showing
23 changed files
with
174 additions
and
56 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test/cases/auxiliaryAssets/expected/webpack-5/auxiliaryAssets-815babffe97b00a1f30b.woff2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
auxiliaryAssets-815babffe97b00a1f30b.woff2 |
1 change: 1 addition & 0 deletions
1
test/cases/auxiliaryAssets/expected/webpack-5/auxiliaryAssets-a0de923c946d4ccb38b0.ttf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
auxiliaryAssets-a0de923c946d4ccb38b0.ttf |
1 change: 1 addition & 0 deletions
1
test/cases/auxiliaryAssets/expected/webpack-5/auxiliaryAssets-d4c409dfe110747b1763.woff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
auxiliaryAssets-d4c409dfe110747b1763.woff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@font-face { | ||
font-family: 'Roboto'; | ||
font-style: normal; | ||
font-weight: 300; | ||
font-display: swap; | ||
src: local('Roboto Light'), local('Roboto-Light'), | ||
url('fonts/roboto-v18-latin-300.woff2') format('woff2'), | ||
url('fonts/roboto-v18-latin-300.woff') format('woff'), | ||
url('fonts/roboto-v18-latin-300.ttf') format('truetype'); | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './fonts.css'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import Self from '../../../src'; | ||
|
||
class AssetsPlugin { | ||
// eslint-disable-next-line class-methods-use-this | ||
apply(compiler) { | ||
compiler.hooks.emit.tapAsync('AssetsPlugin', (compilation, cb) => { | ||
const stats = compilation.getStats().toJson({ | ||
all: true, | ||
}); | ||
|
||
const { RawSource } = compiler.webpack.sources; | ||
|
||
for (const file of stats.entrypoints.main.auxiliaryAssets) { | ||
const newFile = `auxiliaryAssets-${file.name}`; | ||
compilation.emitAsset(newFile, new RawSource(newFile), {}); | ||
} | ||
|
||
cb(); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = { | ||
entry: './index.js', | ||
mode: 'development', | ||
output: { | ||
publicPath: '/', | ||
}, | ||
optimization: { | ||
sideEffects: true, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(woff2?|ttf|eot|otf|png|jpe?g|gif|ico|svg|webp)$/, | ||
type: 'asset', | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
{ | ||
loader: Self.loader, | ||
options: { | ||
esModule: true, | ||
}, | ||
}, | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
esModule: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new Self({ | ||
filename: '[name].css', | ||
chunkFilename: '[id].[name].css', | ||
}), | ||
new AssetsPlugin(), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.