From 311b5e538d115071c0ea6a36d43ef72d45d07b32 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Sun, 25 Feb 2018 22:49:50 -0700 Subject: [PATCH] Only create reference to vendor.dll.js in developement Also changed filenames to fit with more modern webpack conventions --- ui/package.json | 12 +++++++----- ui/src/index.template.html | 1 - ui/webpack/{devConfig.js => dev.config.js} | 14 ++++++++++++++ ui/webpack/{prodConfig.js => prod.config.js} | 0 ui/yarn.lock | 18 +++++++++++++++++- 5 files changed, 38 insertions(+), 7 deletions(-) rename ui/webpack/{devConfig.js => dev.config.js} (94%) rename ui/webpack/{prodConfig.js => prod.config.js} (100%) diff --git a/ui/package.json b/ui/package.json index 70fd9499d..4de115a3c 100644 --- a/ui/package.json +++ b/ui/package.json @@ -9,12 +9,12 @@ "url": "github:influxdata/chronograf" }, "scripts": { - "build": "yarn run clean && webpack --config ./webpack/prodConfig.js", - "build:dev": "webpack --config ./webpack/devConfig.js", + "build": "yarn run clean && webpack --config ./webpack/prod.config.js", + "build:dev": "webpack --config ./webpack/dev.config.js", "build:vendor": "webpack --config webpack/vendor.config.js", - "start": "yarn run clean && yarn run build:vendor && webpack --watch --config ./webpack/devConfig.js", - "start:assets": "webpack --watch --config ./webpack/devConfig.js", - "start:hmr": "webpack-dev-server --open --config ./webpack/devConfig.js", + "start": "yarn run clean && yarn run build:vendor && webpack --watch --config ./webpack/dev.config.js", + "start:assets": "webpack --watch --config ./webpack/dev.config.js", + "start:hmr": "webpack-dev-server --open --config ./webpack/dev.config.js", "lint": "esw src/", "test": "karma start --single-run", "test:lint": "yarn run lint; yarn run test", @@ -35,6 +35,7 @@ "@types/mocha": "^2.2.48", "@types/node": "^9.4.6", "@types/react": "^16.0.38", + "add-asset-html-webpack-plugin": "^2.1.2", "autoprefixer": "^6.3.1", "babel-core": "^6.5.1", "babel-eslint": "6.1.2", @@ -70,6 +71,7 @@ "fork-ts-checker-webpack-plugin": "^0.3.0", "hanson": "^1.1.1", "hson-loader": "^1.0.0", + "html-webpack-include-assets-plugin": "^1.0.2", "html-webpack-plugin": "^2.30.1", "imports-loader": "^0.6.5", "jsdom": "^9.0.0", diff --git a/ui/src/index.template.html b/ui/src/index.template.html index e363c9738..1ebed4a16 100644 --- a/ui/src/index.template.html +++ b/ui/src/index.template.html @@ -8,7 +8,6 @@
- diff --git a/ui/webpack/devConfig.js b/ui/webpack/dev.config.js similarity index 94% rename from ui/webpack/devConfig.js rename to ui/webpack/dev.config.js index b5c6c9f94..00a8d3b24 100644 --- a/ui/webpack/devConfig.js +++ b/ui/webpack/dev.config.js @@ -4,6 +4,7 @@ const webpack = require('webpack') const ExtractTextPlugin = require('extract-text-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin') const WebpackOnBuildPlugin = require('on-build-webpack') +const HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin') const keys = require('lodash/keys') const difference = require('lodash/difference') const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin') @@ -20,6 +21,11 @@ const babelLoader = { }, } +const log = function(x) { + console.log('IM LOGGIN HERE: ', x) + return x +} + module.exports = { node: { fs: 'empty', @@ -152,6 +158,10 @@ module.exports = { inject: 'body', favicon: 'assets/images/favicon.ico', }), + new HtmlWebpackIncludeAssetsPlugin({ + assets: ['vendor.dll.js'], + append: false, + }), new webpack.DefinePlugin({ VERSION: JSON.stringify(require('../package.json').version), }), @@ -167,6 +177,10 @@ module.exports = { const filesToRemove = difference(buildDirFiles, assetFileNames) for (const file of filesToRemove) { + if (file.includes('dll')) { + return + } + const ext = path.extname(file) if (['.js', '.json', '.map'].includes(ext)) { fs.unlink(path.join(buildDir, file), unlinkErr => { diff --git a/ui/webpack/prodConfig.js b/ui/webpack/prod.config.js similarity index 100% rename from ui/webpack/prodConfig.js rename to ui/webpack/prod.config.js diff --git a/ui/yarn.lock b/ui/yarn.lock index 1549110c8..9be32cef3 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -98,6 +98,14 @@ acorn@^5.0.0, acorn@^5.2.1, acorn@^5.3.0, acorn@^5.4.0, acorn@^5.4.1: version "5.4.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.4.1.tgz#fdc58d9d17f4a4e98d102ded826a9b9759125102" +add-asset-html-webpack-plugin@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/add-asset-html-webpack-plugin/-/add-asset-html-webpack-plugin-2.1.2.tgz#b3e60192602cdc53f03f2b19b7de36b5c4a6c7fe" + dependencies: + bluebird "^3.5.0" + globby "^6.1.0" + minimatch "^3.0.4" + add-px-to-style@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/add-px-to-style/-/add-px-to-style-1.0.0.tgz#d0c135441fa8014a8137904531096f67f28f263a" @@ -1329,7 +1337,7 @@ block-stream@*: dependencies: inherits "~2.0.0" -bluebird@^3.1.1, bluebird@^3.3.0, bluebird@^3.4.6, bluebird@^3.4.7, bluebird@^3.5.1: +bluebird@^3.1.1, bluebird@^3.3.0, bluebird@^3.4.6, bluebird@^3.4.7, bluebird@^3.5.0, bluebird@^3.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" @@ -4255,6 +4263,14 @@ html-minifier@^3.2.3: relateurl "0.2.x" uglify-js "3.3.x" +html-webpack-include-assets-plugin@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/html-webpack-include-assets-plugin/-/html-webpack-include-assets-plugin-1.0.2.tgz#8d36eadb81e9e6bf40b56dc2ae77c3d155295106" + dependencies: + glob "^7.1.2" + minimatch "^3.0.4" + slash "^1.0.0" + html-webpack-plugin@^2.30.1: version "2.30.1" resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-2.30.1.tgz#7f9c421b7ea91ec460f56527d78df484ee7537d5"