-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
68 additions
and
110 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Configuration } from "webpack"; | ||
|
||
declare function createWebpackConfig(fixture: string): Configuration; |
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,61 @@ | ||
import HtmlBundlerPlugin from "html-bundler-webpack-plugin"; | ||
import { resolve } from "path"; | ||
|
||
/** | ||
* @param {string} fixture | ||
* @returns {import('webpack').Configuration} | ||
*/ | ||
export function createWebpackConfig(fixture) { | ||
return { | ||
mode: "production", | ||
devtool: "source-map", | ||
context: resolve(import.meta.dirname, "fixture", fixture), | ||
entry: "./index.html", | ||
output: { | ||
path: resolve(import.meta.dirname, "../artifacts/integration"), | ||
filename: "bundle.js", | ||
publicPath: "/path/to/public/", | ||
assetModuleFilename: "[name].public[ext][query]", | ||
}, | ||
plugins: [ | ||
new HtmlBundlerPlugin({ | ||
entry: { | ||
index: "index.html", | ||
}, | ||
loaderOptions: { | ||
sources: [ | ||
{ | ||
tag: "meta", | ||
attributes: ["content"], | ||
filter: ({ attributes: { name } }) => | ||
name === "msapplication-config" || | ||
name === "msapplication-TileImage", | ||
}, | ||
], | ||
}, | ||
}), | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(png|xml)$/, | ||
type: "asset/resource", | ||
}, | ||
{ | ||
test: /\/browserconfig\.xml$/i, | ||
type: "asset/resource", | ||
use: resolve(import.meta.dirname, "../artifacts/dist/esm/index.js"), | ||
}, | ||
{ | ||
test: /\/notification-[135]\.xml$/i, | ||
type: "asset/resource", | ||
generator: { | ||
emit: false, | ||
filename: "[name][ext]", | ||
publicPath: "https://cdn.example.com/", | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,62 +1,7 @@ | ||
import HtmlBundlerPlugin from "html-bundler-webpack-plugin"; | ||
import { resolve } from "path"; | ||
import { createWebpackConfig } from "./create-webpack-config.js"; | ||
|
||
const fixture = process.env.FIXTURE; | ||
|
||
if (!fixture) throw new Error("FIXTURE is required"); | ||
|
||
/** @type {import('webpack').Configuration} */ | ||
const config = { | ||
mode: "production", | ||
devtool: "source-map", | ||
context: resolve(import.meta.dirname, "fixture", fixture), | ||
entry: "./index.html", | ||
output: { | ||
path: resolve(import.meta.dirname, "../artifacts/integration"), | ||
filename: "bundle.js", | ||
publicPath: "/path/to/public/", | ||
assetModuleFilename: "[name].public[ext][query]", | ||
}, | ||
plugins: [ | ||
new HtmlBundlerPlugin({ | ||
entry: { | ||
index: "index.html", | ||
}, | ||
loaderOptions: { | ||
sources: [ | ||
{ | ||
tag: "meta", | ||
attributes: ["content"], | ||
filter: ({ attributes: { name } }) => | ||
name === "msapplication-config" || | ||
name === "msapplication-TileImage", | ||
}, | ||
], | ||
}, | ||
}), | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(png|xml)$/, | ||
type: "asset/resource", | ||
}, | ||
{ | ||
test: /\/browserconfig\.xml$/i, | ||
type: "asset/resource", | ||
use: resolve(import.meta.dirname, "../artifacts/dist/esm/index.js"), | ||
}, | ||
{ | ||
test: /\/notification-[135]\.xml$/i, | ||
type: "asset/resource", | ||
generator: { | ||
emit: false, | ||
filename: "[name][ext]", | ||
publicPath: "https://cdn.example.com/", | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export default config; | ||
export default createWebpackConfig(fixture); |