-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,155 additions
and
1,790 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,54 @@ | ||
/* eslint-disable global-require */ | ||
|
||
export type TransformUnit = 'keep' | 'to-px' | 'to-rpx'; | ||
|
||
const getTransformUnitsPlugin = (unit: TransformUnit) => { | ||
switch (unit) { | ||
case 'keep': | ||
return []; | ||
case 'to-px': | ||
// use this plugin because some plugins, like postcss-calc, don't support `rpx` unit | ||
return require('./postcssTransformUnit')({ | ||
divisor: 2, | ||
multiple: 1, | ||
sourceUnit: 'rpx', | ||
targetUnit: 'px', | ||
}); | ||
case 'to-rpx': | ||
return require('./postcssTransformUnit')({ | ||
divisor: 1, | ||
multiple: 2, | ||
sourceUnit: 'px', | ||
targetUnit: 'rpx', | ||
}); | ||
default: | ||
throw new Error(`Unknown unit ${unit}`); | ||
} | ||
}; | ||
|
||
// to improve PostCSS performance, we should always use `require(name)(options)` rather than `[name, options]` | ||
// also we should set `postcssOptions.config` to `false` to avoid loading any `postcss.config.js` | ||
// TODO: hope PostCSS could fix this issue https://github.com/csstools/postcss-preset-env/issues/232#issuecomment-992263741 | ||
export default { | ||
plugins: [ | ||
require('postcss-each')(), | ||
// TODO: `postcss-nesting` from `postcss-preset-env` output `:is` pseudo-class that | ||
// Mini Programs don't support. | ||
// We have to `postcss-nested` manually before them to prevent `:is` being created. | ||
require('postcss-nested'), | ||
require('postcss-preset-env')({ | ||
stage: 0, | ||
preserve: false, // for reducing file size | ||
insertAfter: { | ||
// postcss-calc must run before autoprefixer | ||
'environment-variables': require('postcss-calc')(), | ||
}, | ||
}), | ||
// use postcss-px2units because some plugins, like postcss-calc, don't support `rpx` unit | ||
require('./postcssPx2units')({ | ||
multiple: 2, | ||
targetUnits: 'rpx', | ||
}), | ||
require('cssnano')({ preset: 'default' }), | ||
require('postcss-reporter')({ clearReportedMessages: true }), | ||
], | ||
export default ({ unit }: { unit: TransformUnit }) => { | ||
const transformUnitPlugin = getTransformUnitsPlugin(unit); | ||
|
||
return { | ||
plugins: [ | ||
require('postcss-each')(), | ||
// TODO: `postcss-nesting` from `postcss-preset-env` output `:is` pseudo-class that Mini Programs don't support. | ||
// We have to use `postcss-nested` manually before them to prevent `:is` being created. | ||
require('postcss-nested'), | ||
require('postcss-preset-env')({ | ||
stage: 0, | ||
preserve: false, | ||
insertAfter: { | ||
// postcss-calc must run before autoprefixer | ||
'environment-variables': require('postcss-calc')(), | ||
}, | ||
}), | ||
...transformUnitPlugin, | ||
require('cssnano')({ preset: 'default' }), | ||
require('postcss-reporter')({ clearReportedMessages: true }), | ||
], | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
module.exports = {}; | ||
module.exports = { | ||
parallel: 0, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { GojiTarget } from '@goji/core'; | ||
// import { GojiTarget } from '@goji/core'; | ||
|
||
export default ({ target }: { target: GojiTarget }) => ({ | ||
pages: ['pages/index/index'], | ||
window: { | ||
backgroundTextStyle: 'dark', | ||
navigationBarBackgroundColor: '#ffffff', | ||
backgroundColor: '#ffffff', | ||
navigationBarTitleText: `TodoMVC Example ${target}`, | ||
navigationBarTextStyle: 'black', | ||
}, | ||
}); | ||
// export default ({ target }: { target: GojiTarget }) => ({ | ||
// pages: ['pages/index/index'], | ||
// window: { | ||
// backgroundTextStyle: 'dark', | ||
// navigationBarBackgroundColor: '#ffffff', | ||
// backgroundColor: '#ffffff', | ||
// navigationBarTitleText: `TodoMVC Example ${target}`, | ||
// navigationBarTextStyle: 'black', | ||
// }, | ||
// }); | ||
const a: number = 1; |
Oops, something went wrong.