Improve webpack config

This commit is contained in:
a 2020-08-02 20:48:29 +02:00
parent 079acca33c
commit b549d619e7
6 changed files with 34 additions and 12 deletions

View file

@ -10,6 +10,7 @@
"clean-webpack-plugin": "^3.0.0", "clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^6.0.3", "copy-webpack-plugin": "^6.0.3",
"css-loader": "^4.0.0", "css-loader": "^4.0.0",
"file-loader": "^6.0.0",
"html-loader": "^1.1.0", "html-loader": "^1.1.0",
"html-webpack-plugin": "4.3.0", "html-webpack-plugin": "4.3.0",
"husky": ">=4", "husky": ">=4",

View file

@ -1,4 +1,4 @@
import spinnerCSS from "./spinner.raw.scss"; import spinnerCSS from "./spinner.scss?file";
export class LingoLoading extends HTMLElement { export class LingoLoading extends HTMLElement {
constructor() { constructor() {
@ -8,7 +8,9 @@ export class LingoLoading extends HTMLElement {
let spinner = document.createElement("div"); let spinner = document.createElement("div");
spinner.id = "spinner"; spinner.id = "spinner";
const style = document.createElement("style"); const style = document.createElement("link");
style.rel = "stylesheet";
style.href = spinnerCSS;
style.textContent = spinnerCSS; style.textContent = spinnerCSS;
shadow.appendChild(style); shadow.appendChild(style);
shadow.appendChild(spinner); shadow.appendChild(spinner);

6
src/types.d.ts vendored
View file

@ -1,6 +1,6 @@
declare module "*.raw.scss" { declare module "*?file" {
const css: string; const file: string;
export = css; export = file;
} }
declare const enum commands { declare const enum commands {

View file

@ -36,17 +36,28 @@ let options = {
}, },
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
use: "ts-loader", oneOf: [
{
resourceQuery: /file/,
use: ["ts-loader", "file-loader"],
},
{
use: "ts-loader",
},
],
exclude: /node_modules/, exclude: /node_modules/,
}, },
{ {
test: /\.(c|s[ac])ss$/i, test: /\.(c|s[ac])ss$/i,
exclude: /\.raw\.(c|s[ac])ss$/i, oneOf: [
use: ["style-loader", "css-loader", "sass-loader"], {
}, resourceQuery: /file/,
{ use: ["file-loader", "css-loader", "sass-loader"],
test: /\.raw\.(c|s[ac])ss$/i, },
use: ["raw-loader", "sass-loader"], {
use: ["style-loader", "css-loader", "sass-loader"],
},
],
}, },
], ],
}, },

View file

@ -2463,6 +2463,14 @@ file-entry-cache@^5.0.1:
dependencies: dependencies:
flat-cache "^2.0.1" flat-cache "^2.0.1"
file-loader@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/file-loader/-/file-loader-6.0.0.tgz#97bbfaab7a2460c07bcbd72d3a6922407f67649f"
integrity sha512-/aMOAYEFXDdjG0wytpTL5YQLfZnnTmLNjn+AIrJ/6HVnTfDqLsVKUUwkDf4I4kgex36BvjuXEn/TX9B/1ESyqQ==
dependencies:
loader-utils "^2.0.0"
schema-utils "^2.6.5"
file-uri-to-path@1.0.0: file-uri-to-path@1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"