Skip to content

Commit 6e9b819

Browse files
author
Andrew Welch
committed
Tailwind 2.x problem checkin
1 parent cb44d90 commit 6e9b819

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+21972
-19041
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Tailwind CSS Performance
22

3-
Small repo to demonstrate the slow building of Tailwind CSS using `webpack-dev-server` HMR & PostCSS.
3+
Small repo to demonstrate the slow building of Tailwind CSS 2.0 using `webpack-dev-server` HMR & PostCSS.
44

5-
## Problem
5+
## Problem - Tailwind 2.x
66

7-
This is the Problem branch; you can find the [Solution branch here](https://github.com/nystudio107/tailwind-css-performance/tree/solution)
7+
This is the Problem - Tailwind 2.x branch; you can find the [Solution - Tailwind 1.x branch here](https://github.com/nystudio107/tailwind-css-performance/tree/solution)
88

99
This is written up in detail in the [Speeding Up Tailwind CSS Builds](https://nystudio107.com/blog/speeding-up-tailwind-css-builds) article.
1010

buildchain/.eslintrc

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
"ecmaVersion": 2020,
77
"sourceType": "module"
88
},
9+
"rules": {
10+
"@typescript-eslint/no-var-requires": 0
11+
},
12+
"env": {
13+
"browser": true,
14+
"amd": true,
15+
"node": true
16+
},
917
"plugins": [
1018
"@typescript-eslint"
1119
],

buildchain/get-webpack-config.js

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// node modules
2+
const { merge } = require('webpack-merge');
3+
4+
/**
5+
* return a webpack settings file
6+
* @param name string
7+
* @returns {{}}
8+
*/
9+
const getWebpackSettings = (name) => {
10+
let settings = {};
11+
try {
12+
settings = require('./webpack-settings/' + name + '.settings.js');
13+
} catch (e) {
14+
// that's okay
15+
}
16+
17+
return settings;
18+
};
19+
20+
/**
21+
* return a webpack settings file combined with the 'app' settings
22+
* @param name string
23+
* @returns {{}}
24+
*/
25+
const getCombinedWebpackSettings = (name) => ({
26+
...getWebpackSettings('app'),
27+
...getWebpackSettings(name),
28+
});
29+
30+
/**
31+
* return a legacy webpack config file
32+
* @param name
33+
* @returns {{}}
34+
*/
35+
const getLegacyWebpackConfig = (name) => require('./webpack-configs/' + name + '.config.js')('legacy', getCombinedWebpackSettings(name));
36+
37+
/**
38+
* return a modern webpack config file
39+
* @param name
40+
* @returns {{}}
41+
*/
42+
const getModernWebpackConfig = (name) => require('./webpack-configs/' + name + '.config.js')('modern', getCombinedWebpackSettings(name));
43+
44+
/**
45+
* return an array of webpack configs using the function provided in getWebpackConfig
46+
* @param names string[]
47+
* @param getWebpackConfig function
48+
* @returns {{}}
49+
*/
50+
const webpackConfigs = (names, getWebpackConfig) => {
51+
let config = {};
52+
names.forEach((name) => config = merge(config, getWebpackConfig(name)));
53+
54+
return config;
55+
};
56+
57+
/**
58+
* return an array of build webpack configs
59+
* @param names string
60+
* @returns {{}}
61+
*/
62+
const buildWebpackConfigs = (...names) => webpackConfigs(names, getModernWebpackConfig);
63+
64+
/**
65+
* return an array of legacy webpack configs
66+
* @param names string
67+
* @returns {{}}
68+
*/
69+
const legacyWebpackConfigs = (...names) => webpackConfigs(names, getLegacyWebpackConfig);
70+
71+
/**
72+
* return an array of modern webpack configs
73+
* @param names string
74+
* @returns {{}}
75+
*/
76+
const modernWebpackConfigs = (...names) => webpackConfigs(names, getModernWebpackConfig);
77+
78+
// module exports
79+
module.exports = {
80+
getWebpackSettings,
81+
getLegacyWebpackConfig,
82+
getModernWebpackConfig,
83+
buildWebpackConfigs,
84+
legacyWebpackConfigs,
85+
modernWebpackConfigs,
86+
};

0 commit comments

Comments
 (0)