Merge pull request #2117 from thelounge/webpack4

Upgrade to webpack 4; tracking pr
This commit is contained in:
Pavel Djundik 2018-04-06 12:59:07 +03:00 committed by GitHub
commit 6626fbcfbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 1495 additions and 539 deletions

9
client/css/fontawesome.css vendored Normal file
View file

@ -0,0 +1,9 @@
@font-face {
/* We use free solid icons - https://fontawesome.com/icons?s=solid&m=free */
font-family: "FontAwesome";
font-weight: normal;
font-style: normal;
src:
url("../fonts/fa-solid-900.woff2") format("woff2"),
url("../fonts/fa-solid-900.woff") format("woff");
}

View file

@ -1,12 +1,6 @@
@font-face {
/* We use free solid icons - https://fontawesome.com/icons?s=solid&m=free */
font-family: "FontAwesome";
font-weight: normal;
font-style: normal;
src:
url("../fonts/fa-solid-900.woff2") format("woff2"),
url("../fonts/fa-solid-900.woff") format("woff");
}
@import "fontawesome.css";
@import "bootstrap.css";
@import "../../node_modules/primer-tooltips/build/build.css";
html,
body {

View file

@ -7,8 +7,6 @@
<link rel="preload" as="script" href="js/bundle.vendor.js">
<link rel="preload" as="script" href="js/bundle.js">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/primer-tooltips.css">
<link rel="stylesheet" href="css/style.css">
<link id="theme" rel="stylesheet" href="themes/<%- theme %>.css" data-server-theme="<%- theme %>">
<% _.forEach(stylesheets, function(css) { %>

View file

@ -67,24 +67,26 @@
"devDependencies": {
"@fortawesome/fontawesome-free-webfonts": "1.0.5",
"babel-core": "6.26.0",
"babel-loader": "7.1.2",
"babel-loader": "7.1.4",
"babel-preset-env": "1.6.1",
"chai": "4.1.2",
"copy-webpack-plugin": "4.5.1",
"css-loader": "0.28.11",
"css.escape": "1.5.1",
"emoji-regex": "6.5.1",
"eslint": "4.19.1",
"fuzzy": "0.1.3",
"graphql-request": "1.5.1",
"handlebars": "4.0.11",
"handlebars-loader": "1.6.0",
"handlebars-loader": "1.7.0",
"intersection-observer": "0.5.0",
"istanbul-instrumenter-loader": "3.0.1",
"jquery": "3.3.1",
"jquery-ui": "1.12.1",
"mini-css-extract-plugin": "0.4.0",
"mocha": "5.0.5",
"mocha-loader": "1.1.3",
"mocha-webpack": "1.0.1",
"mocha-webpack": "2.0.0-beta.0",
"mousetrap": "1.6.1",
"npm-run-all": "4.1.2",
"nyc": "11.6.0",
@ -94,7 +96,8 @@
"stylelint-config-standard": "18.2.0",
"textcomplete": "0.17.1",
"undate": "0.2.4",
"webpack": "3.11.0",
"webpack-dev-server": "2.11.1"
"webpack": "4.5.0",
"webpack-cli": "2.0.14",
"webpack-dev-server": "3.1.1"
}
}

View file

@ -29,7 +29,7 @@ if (!fs.existsSync(path.join(
"public",
"manifest.json"
))) {
log.error(`The client application was not built. Run ${colors.bold("NODE_ENV=production npm run build")} to resolve this.`);
log.error(`The client application was not built. Run ${colors.bold("NODE_ENV=production yarn build")} to resolve this.`);
process.exit(1);
}

View file

@ -10,7 +10,7 @@ config.entry = {
// Instrumentation for testing with mocha
config.module.rules.push({
test: /\.js$/,
include: path.join(__dirname, "test/client"),
include: path.join(__dirname, "test/client/js/*"),
use: "mocha-loader",
});

View file

@ -1,7 +1,6 @@
"use strict";
const path = require("path");
const webpack = require("webpack");
const config = require("./webpack.config.js");
config.target = "node";
@ -17,10 +16,9 @@ config.module.rules.push({
enforce: "post",
});
// `CommonsChunkPlugin` is incompatible with a `target` of `node`.
// See https://github.com/zinserjan/mocha-webpack/issues/84
config.plugins = config.plugins.filter((a) =>
!(a instanceof webpack.optimize.CommonsChunkPlugin)
);
// `optimization.splitChunks` is incompatible with a `target` of `node`. See:
// - https://github.com/zinserjan/mocha-webpack/issues/84
// - https://github.com/webpack/webpack/issues/6727#issuecomment-372589122
config.optimization.splitChunks = false;
module.exports = config;

View file

@ -3,14 +3,13 @@
const webpack = require("webpack");
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
// ********************
// Common configuration
// ********************
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const config = {
mode: process.env.NODE_ENV === "production" ? "production" : "development",
entry: {
"js/bundle.js": path.resolve(__dirname, "client/js/lounge.js"),
"css/style": path.resolve(__dirname, "client/css/style.css"),
},
devtool: "source-map",
output: {
@ -20,6 +19,22 @@ const config = {
},
module: {
rules: [
{
test: /\.css$/,
include: [
path.resolve(__dirname, "client"),
],
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
url: false,
minimize: process.env.NODE_ENV === "production",
},
},
],
},
{
test: /\.js$/,
include: [
@ -57,10 +72,22 @@ const config = {
},
],
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: "js/bundle.vendor.js",
chunks: "all",
},
},
},
},
externals: {
json3: "JSON", // socket.io uses json3.js, but we do not target any browsers that need it
},
plugins: [
new MiniCssExtractPlugin(),
new CopyPlugin([
{
from: "./node_modules/@fortawesome/fontawesome-free-webfonts/webfonts/fa-solid-900.woff*",
@ -87,34 +114,10 @@ const config = {
from: "./client/themes/*",
to: "themes/[name].[ext]",
},
{ // TODO: Build css with postcss
from: "./client/css/*",
to: "css/[name].[ext]",
},
{
from: "./node_modules/primer-tooltips/build/build.css",
to: "css/primer-tooltips.[ext]",
},
]),
// socket.io uses debug, we don't need it
new webpack.NormalModuleReplacementPlugin(/debug/, path.resolve(__dirname, "scripts/noop.js")),
// automatically split all vendor dependencies into a separate bundle
new webpack.optimize.CommonsChunkPlugin({
name: "js/bundle.vendor.js",
minChunks: (module) => module.context && module.context.includes("node_modules"),
}),
],
};
// *********************************
// Production-specific configuration
// *********************************
if (process.env.NODE_ENV === "production") {
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
comments: false,
}));
}
module.exports = config;

1925
yarn.lock

File diff suppressed because it is too large Load diff