-
-
Notifications
You must be signed in to change notification settings - Fork 79
/
resourceLoader.js
57 lines (50 loc) · 1.48 KB
/
resourceLoader.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
import path from 'path'
const WEBPACK_DIRECTORY = '_webpack_resources'
const resourceRegex = /^(?!.*\.(jsx?|tsx?|json|nib|xib|framework|xcodeproj|xcworkspace|xcworkspacedata|pbxproj)$).*/ // match everything except .jsx?, .tsx?, json, xib and nib
export const commandResourceLoader = {
test: resourceRegex,
use: {
loader: '@skpm/file-loader',
query: {
raw: true,
outputPath(url) {
return path.posix.join('..', 'Resources', WEBPACK_DIRECTORY, url)
},
publicPath(url) {
return `"file://" + String(context.scriptPath).split(".sketchplugin/Contents/Sketch")[0] + ".sketchplugin/Contents/Resources/${WEBPACK_DIRECTORY}/${url}"`
},
},
},
}
const nibRegex = /\.(nib|xib)?$/ // match xib or nib
export const nibLoader = {
test: nibRegex,
use: {
loader: '@skpm/nib-loader',
query: {
raw: true,
outputPath(url) {
return path.posix.join('..', 'Resources', WEBPACK_DIRECTORY, url)
},
publicPath(url) {
return `${WEBPACK_DIRECTORY}/${url}`
},
},
},
}
const xcodeprojRegex = /\.(framework|xcodeproj|xcworkspace|xcworkspacedata|pbxproj)?$/ // match xcodeproj
export const xcodeprojLoader = {
test: xcodeprojRegex,
use: {
loader: '@skpm/xcodeproj-loader',
query: {
raw: true,
outputPath(url) {
return path.posix.join('..', 'Resources', WEBPACK_DIRECTORY, url)
},
publicPath(url) {
return `${WEBPACK_DIRECTORY}/${url}`
},
},
},
}