Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(examples): taro example support tailwindcss #26

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion examples/taro-app/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig, type UserConfigExport } from '@tarojs/cli'
import { UnifiedWebpackPluginV5 } from 'weapp-tailwindcss/webpack';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
import devConfig from './dev'
import prodConfig from './prod'
Expand Down Expand Up @@ -69,7 +70,17 @@ export default defineConfig(async (merge, { command, mode }) => {
}
},
webpackChain(chain) {
chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin)
chain.resolve.plugin('tsconfig-paths').use(TsconfigPathsPlugin);
chain.merge({
plugin: {
install: {
plugin: UnifiedWebpackPluginV5,
args: [{
appType: 'taro'
}]
}
}
})
}
},
h5: {
Expand Down
7 changes: 4 additions & 3 deletions examples/taro-app/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

const plugins = {
'@pandacss/dev/postcss': {},
let plugins = {
tailwindcss: {},
'@pandacss/dev/postcss': {}
}
// https://taro-docs.jd.com/docs/envs#processenvtaro_env
if (process.env.TARO_ENV !== 'h5' && process.env.TARO_ENV !== 'rn') {
Expand All @@ -9,6 +9,7 @@ if (process.env.TARO_ENV !== 'h5' && process.env.TARO_ENV !== 'rn') {
plugins['weapp-pandacss/postcss'] = options
}

plugins['autoprefixer'] = {}

module.exports = {
plugins
Expand Down
4 changes: 4 additions & 0 deletions examples/taro-app/src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@
}
/* ... */
}

@import 'tailwindcss/base';
@import 'tailwindcss/utilities';
@import 'tailwindcss/components';
4 changes: 4 additions & 0 deletions examples/taro-app/src/pages/index/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ export default function Index() {
>
Hello
</dViewiv>

<View className='px-4 py-1 text-center bg-slate-400'>
TAILWIND
</View>
</View>
)
}
9 changes: 9 additions & 0 deletions examples/taro-app/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./public/index.html', './src/**/*.{html,js,ts,jsx,tsx,vue}'],
theme: {
extend: {},
},
plugins: [],
}