Skip to content

Commit b2a4fb9

Browse files
committed
feat(packages/sui-bundler): add tailwind support
1 parent b729a47 commit b2a4fb9

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

packages/sui-bundler/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@
4646
"stream-http": "3.2.0",
4747
"strip-ansi": "6.0.1",
4848
"style-loader": "3.3.1",
49+
"tailwindcss": "3.2.7",
4950
"url": "0.11.0",
5051
"webpack": "5.74.0",
5152
"webpack-dev-server": "4.10.0",
5253
"webpack-manifest-plugin": "5.0.0",
5354
"webpack-node-externals": "3.0.0"
5455
}
55-
}
56+
}

packages/sui-bundler/shared/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const fs = require('fs')
12
const {config} = require('./config.js')
23

34
exports.MAIN_ENTRY_POINT = './app.js'
@@ -7,6 +8,9 @@ exports.cleanList = list => list.filter(Boolean)
78

89
exports.when = (check, getValue) => (check ? getValue() : false)
910

11+
exports.isTailwindEnabled = () =>
12+
fs.existsSync(`${process.cwd()}/tailwind.config.js`)
13+
1014
exports.envVars = (env = []) =>
1115
env.reduce(
1216
(acc, variable) => {

packages/sui-bundler/shared/module-rules-sass.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
22

3-
const {cleanList, config, when} = require('./index')
3+
const {cleanList, config, when, isTailwindEnabled} = require('./index')
44

55
module.exports = {
66
test: /(\.css|\.scss)$/,
@@ -18,6 +18,7 @@ module.exports = {
1818
options: {
1919
postcssOptions: {
2020
plugins: [
21+
...(isTailwindEnabled() ? [require('tailwindcss').default()] : []),
2122
require('autoprefixer')({
2223
overrideBrowserslist: config.targets
2324
})

packages/sui-bundler/webpack.config.dev.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const {
99
MAIN_ENTRY_POINT,
1010
config,
1111
cleanList,
12-
when
12+
when,
13+
isTailwindEnabled
1314
} = require('./shared/index.js')
1415
const definePlugin = require('./shared/define.js')
1516
const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js')
@@ -99,6 +100,9 @@ const webpackConfig = {
99100
options: {
100101
postcssOptions: {
101102
plugins: [
103+
...(isTailwindEnabled()
104+
? [require('tailwindcss').default()]
105+
: []),
102106
require('autoprefixer')({
103107
overrideBrowserslist: config.targets
104108
})

0 commit comments

Comments
 (0)