Skip to content
Snippets Groups Projects
Commit a2fa97e3 authored by squidfunk's avatar squidfunk
Browse files

Fixed variable requires where possible in webpack config

parent 6e64975d
No related branches found
No related tags found
No related merge requests found
/*
* 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"
/*
* 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
}
...@@ -20,11 +20,15 @@ ...@@ -20,11 +20,15 @@
* IN THE SOFTWARE. * IN THE SOFTWARE.
*/ */
import * as autoprefixer from "autoprefixer"
import * as mqpacker from "css-mqpacker"
import * as fs from "fs" import * as fs from "fs"
import * as html from "html-minifier" import * as html from "html-minifier"
import * as path from "path" import * as path from "path"
import * as uglify from "uglify-js" import * as uglify from "uglify-js"
import metadata from "./package.json"
import { import {
Configuration, Configuration,
NewModule, NewModule,
...@@ -162,7 +166,6 @@ export default (env?: { prod?: boolean }) => { ...@@ -162,7 +166,6 @@ export default (env?: { prod?: boolean }) => {
context: "src", context: "src",
from: "**/*.html", from: "**/*.html",
transform: (content: string) => { transform: (content: string) => {
const metadata = require(path.resolve(__dirname, "package.json"))
return html.minify(content.toString(), { return html.minify(content.toString(), {
collapseBooleanAttributes: true, collapseBooleanAttributes: true,
includeAutoGeneratedTags: false, includeAutoGeneratedTags: false,
...@@ -201,9 +204,9 @@ export default (env?: { prod?: boolean }) => { ...@@ -201,9 +204,9 @@ export default (env?: { prod?: boolean }) => {
macOS when starting for the first time. This is a quick fix until macOS when starting for the first time. This is a quick fix until
this issue is resolved. See: http://bit.ly/2AsizEn */ this issue is resolved. See: http://bit.ly/2AsizEn */
new EventHooksPlugin({ new EventHooksPlugin({
"watch-run": (compiler: any, cb: () => {}) => { "watch-run": (compiler: any, done: () => {}) => {
compiler.startTime += 10000 compiler.startTime += 10000
cb() done()
}, },
"done": (stats: any) => { "done": (stats: any) => {
stats.startTime -= 10000 stats.startTime -= 10000
...@@ -240,7 +243,7 @@ export default (env?: { prod?: boolean }) => { ...@@ -240,7 +243,7 @@ export default (env?: { prod?: boolean }) => {
/* Register plugin */ /* Register plugin */
config.plugins.push(plugin); config.plugins.push(plugin);
(config.module as NewModule).rules.push({ (config.module as NewModule).rules.push({
test: new RegExp(`${stylesheet}$`), test: new RegExp(stylesheet),
use: plugin.extract({ use: plugin.extract({
use: [ use: [
{ {
...@@ -255,8 +258,8 @@ export default (env?: { prod?: boolean }) => { ...@@ -255,8 +258,8 @@ export default (env?: { prod?: boolean }) => {
options: { options: {
ident: "postcss", ident: "postcss",
plugins: () => [ plugins: () => [
require("autoprefixer")(), autoprefixer(),
require("css-mqpacker") mqpacker
], ],
sourceMap: !(env && env.prod) sourceMap: !(env && env.prod)
} }
...@@ -328,7 +331,7 @@ export default (env?: { prod?: boolean }) => { ...@@ -328,7 +331,7 @@ export default (env?: { prod?: boolean }) => {
/* Apply manifest */ /* Apply manifest */
new EventHooksPlugin({ new EventHooksPlugin({
"after-emit": (compilation: any, cb: () => {}) => { "after-emit": (compilation: any, done: () => {}) => {
const manifest = require(path.resolve("material/manifest.json")) const manifest = require(path.resolve("material/manifest.json"))
Object.keys(compilation.assets).forEach(name => { Object.keys(compilation.assets).forEach(name => {
if (name.match(/\.html/)) { if (name.match(/\.html/)) {
...@@ -339,7 +342,7 @@ export default (env?: { prod?: boolean }) => { ...@@ -339,7 +342,7 @@ export default (env?: { prod?: boolean }) => {
fs.writeFileSync(asset.existsAt, replaced) fs.writeFileSync(asset.existsAt, replaced)
} }
}) })
cb() done()
} }
}) })
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment