From 9b38a97110f6dc6c5d98c859ecb155dbc15af961 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 21 Apr 2017 15:06:52 +0100 Subject: [PATCH 1/3] Fix Webpack conf + conform to a bit more eslint (IDE makes my eyes hurt) + specify windows-specific copies of noParse regexes to stop the olm error Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- webpack.config.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index e32f717702..b3c8532ae1 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,7 +1,7 @@ -var path = require('path'); -var webpack = require('webpack'); -var ExtractTextPlugin = require("extract-text-webpack-plugin"); -var HtmlWebpackPlugin = require('html-webpack-plugin'); +const path = require('path'); +const webpack = require('webpack'); +const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { entry: { @@ -19,11 +19,11 @@ module.exports = { // CSS themes "theme-light": "./src/skins/vector/css/themes/light.scss", - "theme-dark": "./src/skins/vector/css/themes/dark.scss" + "theme-dark": "./src/skins/vector/css/themes/dark.scss", }, module: { preLoaders: [ - { test: /\.js$/, loader: "source-map-loader" } + { test: /\.js$/, loader: "source-map-loader" }, ], loaders: [ { test: /\.json$/, loader: "json" }, @@ -39,7 +39,7 @@ module.exports = { // as webpack inputs.) // 3. ExtractTextPlugin turns that string into a separate asset. loader: ExtractTextPlugin.extract( - "css-raw-loader!postcss-loader?config=postcss.config.js" + "css-raw-loader!postcss-loader?config=postcss.config.js", ), }, { @@ -54,10 +54,12 @@ module.exports = { // there is no need for webpack to parse them - they can just be // included as-is. /highlight\.js\/lib\/languages/, + /highlight\.js\\lib\\languages/, // olm takes ages for webpack to process, and it's already heavily // optimised, so there is little to gain by us uglifying it. /olm\/(javascript\/)?olm\.js$/, + /olm\\(javascript\\)?olm\.js$/, ], }, output: { @@ -83,7 +85,7 @@ module.exports = { // various levels of '.' and '..' // Also, sometimes the resource path is absolute. return path.relative(process.cwd(), info.resourcePath).replace(/^[\/\.]*/, ''); - } + }, }, resolve: { alias: { @@ -106,15 +108,15 @@ module.exports = { plugins: [ new webpack.DefinePlugin({ 'process.env': { - NODE_ENV: JSON.stringify(process.env.NODE_ENV) - } + NODE_ENV: JSON.stringify(process.env.NODE_ENV), + }, }), new ExtractTextPlugin( "bundles/[hash]/[name].css", { - allChunks: true - } + allChunks: true, + }, ), new HtmlWebpackPlugin({ From dd7f9e2d5f1285fc114abd7639012731ddc1e4cb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 21 Apr 2017 19:00:24 +0100 Subject: [PATCH 2/3] argh, fix eslint false positives Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- webpack.config.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index b3c8532ae1..f3912d1e3d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -38,9 +38,7 @@ module.exports = { // would also drag in the imgs and fonts that our CSS refers to // as webpack inputs.) // 3. ExtractTextPlugin turns that string into a separate asset. - loader: ExtractTextPlugin.extract( - "css-raw-loader!postcss-loader?config=postcss.config.js", - ), + loader: ExtractTextPlugin.extract("css-raw-loader!postcss-loader?config=postcss.config.js"), }, { // this works similarly to the scss case, without postcss. @@ -112,12 +110,9 @@ module.exports = { }, }), - new ExtractTextPlugin( - "bundles/[hash]/[name].css", - { - allChunks: true, - }, - ), + new ExtractTextPlugin("bundles/[hash]/[name].css", { + allChunks: true, + }), new HtmlWebpackPlugin({ template: './src/vector/index.html', From 08fb20a0dfa327d89cb9b1980312997f18eea242 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 22 Apr 2017 14:02:18 +0100 Subject: [PATCH 3/3] use a character class for brevity add a comment so this madness has meaning Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- webpack.config.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index f3912d1e3d..efeab7fe8b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -47,17 +47,18 @@ module.exports = { }, ], noParse: [ + // for cross platform compatibility use [\\\/] as the path separator + // this ensures that the regex trips on both Windows and *nix + // don't parse the languages within highlight.js. They cause stack // overflows (https://github.com/webpack/webpack/issues/1721), and // there is no need for webpack to parse them - they can just be // included as-is. - /highlight\.js\/lib\/languages/, - /highlight\.js\\lib\\languages/, + /highlight\.js[\\\/]lib[\\\/]languages/, // olm takes ages for webpack to process, and it's already heavily // optimised, so there is little to gain by us uglifying it. - /olm\/(javascript\/)?olm\.js$/, - /olm\\(javascript\\)?olm\.js$/, + /olm[\\\/](javascript[\\\/])?olm\.js$/, ], }, output: {