Skip to content

Commit

Permalink
fix(playground): fix safari import error (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed May 24, 2022
1 parent 3807b8c commit a5c8c99
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
7 changes: 7 additions & 0 deletions packages/varlet-cli/src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ export async function compile(cmd: { noUmd: boolean }) {
await removeDir()
await Promise.all([runTask('types', compileTypes), runTask('template highlight', compileTemplateHighlight)])

process.env.TARGET_MODULE = 'module'
await runTask('module', compileModule)

process.env.TARGET_MODULE = 'esm-bundle'
await runTask('esm bundle', () => compileModule('esm-bundle'))

process.env.TARGET_MODULE = 'commonjs'
await runTask('commonjs', () => compileModule('commonjs'))

process.env.TARGET_MODULE = 'umd'
!cmd.noUmd && (await runTask('umd', () => compileModule('umd')))
}
10 changes: 6 additions & 4 deletions packages/varlet-ui-playground/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import { compileFile, File } from '@vue/repl'
import { utoa, atou } from './utils/encode'
import { Snackbar } from '@varlet/ui'

const publicPath = process.env.NODE_ENV === 'production' ? 'https://varlet-ui-playground.vercel.app/' : './'

const defaultMainFile = 'App.vue'
const varletReplPlugin = 'varlet-repl-plugin.js'
const varletImports = {
'@varlet/ui': './varlet.esm.js',
'@varlet/touch-emulator': './varlet-touch-emulator.js',
'@varlet/ui/json/area.json': './varlet-area.js',
'@varlet/ui': `${publicPath}varlet.esm.js`,
'@varlet/touch-emulator': `${publicPath}varlet-touch-emulator.js`,
'@varlet/ui/json/area.json': `${publicPath}varlet-area.js`,
}
const varletCss = './varlet.css'
const varletCss = `${publicPath}varlet.css`

const welcomeCode = `\
<script setup lang='ts'>
Expand Down
14 changes: 9 additions & 5 deletions packages/varlet-ui/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
module.exports = {
plugins: {
'postcss-px-to-viewport': {
module.exports = () => {
const plugins = {}

if (!process.env.TARGET_MODULE) {
plugins['postcss-px-to-viewport'] = {
viewportWidth: 375,
unitPrecision: 6,
unitToConvert: 'px',
propList: ['*'],
exclude: [/site\/components\//, /site\/pc/],
},
},
}
}

return { plugins }
}

0 comments on commit a5c8c99

Please sign in to comment.