Skip to content

Commit cc7219a

Browse files
author
Martynas Žilinskas
committed
v0.1.0-alpha.12
1 parent 7f11792 commit cc7219a

File tree

4 files changed

+57
-27
lines changed

4 files changed

+57
-27
lines changed

package-lock.json

Lines changed: 35 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@simplrjs/webpack",
3-
"version": "0.1.0-alpha.11",
3+
"version": "0.1.0-alpha.12",
44
"description": "Tailored webpack for SPA.",
55
"publishConfig": {
66
"access": "public"
@@ -69,6 +69,7 @@
6969
"style-loader": "^0.21.0",
7070
"ts-loader": "^4.4.1",
7171
"tsconfig-paths-webpack-plugin": "^3.2.0",
72+
"url-loader": "^1.1.1",
7273
"worker-loader": "^2.0.0",
7374
"write-file-webpack-plugin": "^4.3.2"
7475
}

src/contracts.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ export interface SimplrWebpackOptions {
2626
staticContentDirectoryOutput?: string;
2727
/**
2828
* Full path is: {outputDirectory} + {fontsDirectoryOutput}
29-
* Example: `./dist` + `./fonts` = `./dist/fonts`
29+
* Example: `./dist` + `./assets/fonts` = `./dist/assets/fonts`
3030
*/
3131
fontsDirectoryOutput?: string;
32+
/**
33+
* Full path is: {outputDirectory} + {imagesDirectoryOutput}
34+
* Example: `./dist` + `./assets/images` = `./dist/assets/images`
35+
*/
36+
imagesDirectoryOutput?: string;
3237
/**
3338
* For websites "/" is enough. For electron-renderer "./".
3439
*

src/webpack-config.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export function generateWebpackConfig(opts: SimplrWebpackOptions): Configuration
2121
outputDirectory: opts.outputDirectory || "./wwwroot",
2222
staticContentDirectory: opts.staticContentDirectory || "./src/static",
2323
staticContentDirectoryOutput: opts.staticContentDirectoryOutput || "./static",
24-
fontsDirectoryOutput: opts.fontsDirectoryOutput || "./fonts",
24+
fontsDirectoryOutput: opts.fontsDirectoryOutput || "./assets/fonts",
25+
imagesDirectoryOutput: opts.imagesDirectoryOutput || "./assets/images",
2526
emitHtml: opts.emitHtml != null ? opts.emitHtml : true,
2627
target: opts.target || "web",
2728
publicPath: opts.publicPath || "/"
@@ -107,9 +108,19 @@ export function generateWebpackConfig(opts: SimplrWebpackOptions): Configuration
107108
test: /\.(woff|woff2|eot|ttf|otf)$/,
108109
options: {
109110
name: `./${options.fontsDirectoryOutput}/[name].[ext]`,
110-
publicPath: opts.publicPath
111+
publicPath: opts.publicPath,
112+
limit: 10000
111113
},
112-
loader: "file-loader"
114+
loader: "url-loader"
115+
},
116+
{
117+
test: /\.(png|jpg|gif|svg)$/,
118+
options: {
119+
name: `./${options.imagesDirectoryOutput}/[name].[ext]`,
120+
publicPath: opts.publicPath,
121+
limit: 10000
122+
},
123+
loader: "url-loader"
113124
}
114125
]
115126
},

0 commit comments

Comments
 (0)