diff --git a/typings/css-mqpacker.d.ts b/typings/css-mqpacker.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..79e245b02abacf9dd18b6982cf27041d07a91605 --- /dev/null +++ b/typings/css-mqpacker.d.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2016-2018 Martin Donath <martin.donath@squidfunk.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +declare module "css-mqpacker" diff --git a/typings/index.d.ts b/typings/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..aa341be0c239a47008932f7bff82598978182725 --- /dev/null +++ b/typings/index.d.ts @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2016-2018 Martin Donath <martin.donath@squidfunk.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +declare module "*.json" { + const value: any + export default value +} diff --git a/webpack.config.ts b/webpack.config.ts index 2e3ee795805df30bc321c577b9592a26ccebc7cd..c219fe7a4bf7a606c3b47a3bbd3a0c2120d8e2ae 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -20,11 +20,15 @@ * IN THE SOFTWARE. */ +import * as autoprefixer from "autoprefixer" +import * as mqpacker from "css-mqpacker" import * as fs from "fs" import * as html from "html-minifier" import * as path from "path" import * as uglify from "uglify-js" +import metadata from "./package.json" + import { Configuration, NewModule, @@ -162,7 +166,6 @@ export default (env?: { prod?: boolean }) => { context: "src", from: "**/*.html", transform: (content: string) => { - const metadata = require(path.resolve(__dirname, "package.json")) return html.minify(content.toString(), { collapseBooleanAttributes: true, includeAutoGeneratedTags: false, @@ -201,9 +204,9 @@ export default (env?: { prod?: boolean }) => { macOS when starting for the first time. This is a quick fix until this issue is resolved. See: http://bit.ly/2AsizEn */ new EventHooksPlugin({ - "watch-run": (compiler: any, cb: () => {}) => { + "watch-run": (compiler: any, done: () => {}) => { compiler.startTime += 10000 - cb() + done() }, "done": (stats: any) => { stats.startTime -= 10000 @@ -240,7 +243,7 @@ export default (env?: { prod?: boolean }) => { /* Register plugin */ config.plugins.push(plugin); (config.module as NewModule).rules.push({ - test: new RegExp(`${stylesheet}$`), + test: new RegExp(stylesheet), use: plugin.extract({ use: [ { @@ -255,8 +258,8 @@ export default (env?: { prod?: boolean }) => { options: { ident: "postcss", plugins: () => [ - require("autoprefixer")(), - require("css-mqpacker") + autoprefixer(), + mqpacker ], sourceMap: !(env && env.prod) } @@ -328,7 +331,7 @@ export default (env?: { prod?: boolean }) => { /* Apply manifest */ new EventHooksPlugin({ - "after-emit": (compilation: any, cb: () => {}) => { + "after-emit": (compilation: any, done: () => {}) => { const manifest = require(path.resolve("material/manifest.json")) Object.keys(compilation.assets).forEach(name => { if (name.match(/\.html/)) { @@ -339,7 +342,7 @@ export default (env?: { prod?: boolean }) => { fs.writeFileSync(asset.existsAt, replaced) } }) - cb() + done() } }) )