From 5573f39d30a8a841983592737049837a994166b2 Mon Sep 17 00:00:00 2001 From: Daniel Perez Alvarez Date: Wed, 24 Oct 2018 19:42:28 -0400 Subject: [PATCH] chore: fix webpack config --- package-lock.json | 65 ++++++++++++++++++++++++++++++++++++ package.json | 2 ++ test/automate/setup/index.ts | 13 +++++--- 3 files changed, 76 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index f678da2..cb28cb3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3515,6 +3515,38 @@ "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", "dev": true }, + "copy-webpack-plugin": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-4.5.4.tgz", + "integrity": "sha512-0lstlEyj74OAtYMrDxlNZsU7cwFijAI3Ofz2fD6Mpo9r4xCv4yegfa3uHIKvZY1NSuOtE9nvG6TAhJ+uz9gDaQ==", + "dev": true, + "requires": { + "cacache": "^10.0.4", + "find-cache-dir": "^1.0.0", + "globby": "^7.1.1", + "is-glob": "^4.0.0", + "loader-utils": "^1.1.0", + "minimatch": "^3.0.4", + "p-limit": "^1.0.0", + "serialize-javascript": "^1.4.0" + }, + "dependencies": { + "globby": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-7.1.1.tgz", + "integrity": "sha1-+yzP+UAfhgCUXfral0QMypcrhoA=", + "dev": true, + "requires": { + "array-union": "^1.0.1", + "dir-glob": "^2.0.0", + "glob": "^7.1.2", + "ignore": "^3.3.5", + "pify": "^3.0.0", + "slash": "^1.0.0" + } + } + } + }, "core-js": { "version": "2.5.7", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", @@ -6067,6 +6099,39 @@ } } }, + "html-webpack-include-assets-plugin": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/html-webpack-include-assets-plugin/-/html-webpack-include-assets-plugin-1.0.6.tgz", + "integrity": "sha512-UG+LE180RabNogyOVo0DTH3Ck9EOguwCSu4IfNf3v/xFjeudeYDOpu/r0VH2Xbt52cMTcEY0gZWTrIP7twPv2w==", + "dev": true, + "requires": { + "glob": "^7.1.3", + "minimatch": "^3.0.4", + "slash": "^2.0.0" + }, + "dependencies": { + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + } + } + }, "html-webpack-plugin": { "version": "3.2.0", "resolved": "http://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz", diff --git a/package.json b/package.json index e33579c..d4393de 100644 --- a/package.json +++ b/package.json @@ -55,9 +55,11 @@ "@types/node": "^9.6.0", "@types/selenium-webdriver": "^3.0.10", "@types/webpack": "^4.4.17", + "copy-webpack-plugin": "^4.5.4", "css-loader": "^1.0.0", "expect": "^23.6.0", "express": "^4.16.3", + "html-webpack-include-assets-plugin": "^1.0.6", "html-webpack-plugin": "^3.2.0", "husky": "^1.1.1", "lynt": "^0.5.3", diff --git a/test/automate/setup/index.ts b/test/automate/setup/index.ts index 6f675a3..d9e3470 100644 --- a/test/automate/setup/index.ts +++ b/test/automate/setup/index.ts @@ -1,3 +1,5 @@ +import CopyWebpackPlugin from "copy-webpack-plugin" +import HtmlWebpackIncludeAssetsPlugin from "html-webpack-include-assets-plugin" import HtmlWebpackPlugin from "html-webpack-plugin" import * as http from "http" import express = require("express") @@ -7,14 +9,13 @@ import webpack from "webpack" class Server { private root = resolve(__dirname, "../../../") private outDir = resolve(__dirname, "_static") - private bundleName = "bundle.js" private server: http.Server = (null as any) as http.Server public async generateFiles() { const compiler = webpack({ mode: "production", - entry: [resolve(this.root, "src/browser.ts"), resolve(this.root, "test/local/index.css")], + entry: resolve(this.root, "src/browser.ts"), output: { - filename: this.bundleName, + filename: "[name].js", path: this.outDir, library: "ScrollUtility", libraryTarget: "umd", @@ -41,7 +42,11 @@ class Server { resolve: { extensions: [".ts", ".tsx", ".js"], }, - plugins: [new HtmlWebpackPlugin({ template: resolve(this.root, "test/local/index.html") })], + plugins: [ + new HtmlWebpackPlugin({ template: resolve(this.root, "test/local/index.html") }), + new CopyWebpackPlugin([resolve(this.root, "test/local/index.css")]), + new HtmlWebpackIncludeAssetsPlugin({ assets: ["./index.css"], append: false }), + ], }) return new Promise((s, r) => { compiler.run(err => {