-
Notifications
You must be signed in to change notification settings - Fork 343
/
Copy pathstatic-files.js
99 lines (93 loc) · 2.66 KB
/
static-files.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { buildingManifestV3 } from './util'
/**
* Everything in here gets injected into the generated HTML as link/script tags.
* See: https://github.com/jharris4/html-webpack-include-assets-plugin#example
*/
export const htmlAssets = [
'fonts/Satoshi/satoshi.css',
'lib/browser-polyfill.js',
]
/**
* Set the manifest version to be equal to `package.json` version.
*/
function transformManifestVersion(content) {
const manifest = JSON.parse(content.toString())
manifest.version = process.env.npm_package_version
return Buffer.from(JSON.stringify(manifest))
}
/**
* Set the manifest version to be equal to `package.json` version.
*/
function injectContentScripts(content) {
return Buffer.from(
content.toString().replace(
`</body>`,
`
<script src="../lib/browser-polyfill.js"></script>
<script src="../content_script_pdfjs.js"></script>
</body>
`,
),
)
}
/**
* Everything in here gets copied as-is to the output dir.
* See: https://github.com/webpack-contrib/copy-webpack-plugin#usage
*/
export const copyPatterns = [
{
from: buildingManifestV3 ? 'src/manifest-v3.json' : 'src/manifest.json',
to: './manifest.json',
transform: transformManifestVersion,
},
{ from: 'img', to: 'img' },
{
from: 'node_modules/webextension-polyfill/dist/browser-polyfill.js',
to: 'lib/',
},
{
from: 'node_modules/pdfjs-dist/web/viewer.css',
to: 'pdfjs/',
},
{
from: 'node_modules/pdfjs-dist/web/viewer.js',
to: 'pdfjs/',
},
{
from: 'node_modules/pdfjs-dist/web/viewer.html',
to: 'pdfjs/',
transform: injectContentScripts,
},
{
from: 'node_modules/pdfjs-dist/web/locale/en-US/viewer.properties',
to: 'pdfjs/locale/locale.properties',
},
{
from: 'node_modules/pdfjs-dist/web/locale/en-US/viewer.properties',
to: 'pdfjs/',
},
{
from: 'node_modules/pdfjs-dist/web/images/*',
to: 'pdfjs/images/[name].[ext]',
},
{ from: 'node_modules/pdfjs-dist/build/pdf.js', to: 'build/' },
{ from: 'node_modules/pdfjs-dist/build/pdf.worker.js', to: 'build/' },
{
from: 'node_modules/pdfjs-dist/build/pdf.worker.js',
to: 'build/pdf.worker.min.js',
},
{
from: 'fonts/*/*',
to: 'fonts/[name].[ext]',
},
{
from: 'fonts/Satoshi/*',
to: 'fonts/Satoshi/[name].[ext]',
},
{
from:
'node_modules/material-design-icons/iconfont/*.{eot,ttf,woff,woff2,css}',
to: 'fonts/material-icons/[name].[ext]',
toType: 'template',
},
]