Skip to content

Commit

Permalink
fix(cli): lerna 加入 taro-mini-runner && 接入 webpack 生成小程序文件
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Dec 26, 2019
1 parent d7fb83d commit 961e2f6
Show file tree
Hide file tree
Showing 15 changed files with 757 additions and 29 deletions.
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"packages/taro-qq",
"packages/taro-jd",
"packages/taro-webpack-runner",
"packages/taro-mini-runner",
"packages/postcss-plugin-constparse",
"packages/eslint-config-taro",
"packages/eslint-plugin-taro",
Expand Down
20 changes: 20 additions & 0 deletions packages/taro-mini-runner/src/config/babel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const babelOptions: IBabelOptions = {
sourceMap: true,
presets: [
'env'
],
plugins: [
require('babel-plugin-transform-react-jsx'),
'transform-decorators-legacy',
'transform-class-properties',
'transform-object-rest-spread'
]
}

export default babelOptions

export interface IBabelOptions {
sourceMap: boolean,
presets: string[],
plugins: any[]
}
15 changes: 15 additions & 0 deletions packages/taro-mini-runner/src/config/babylon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default {
sourceType: 'module',
plugins: [
'typescript',
'classProperties',
'jsx',
'trailingFunctionCommas',
'asyncFunctions',
'exponentiationOperator',
'asyncGenerators',
'objectRestSpread',
'decorators',
'dynamicImport'
]
}
5 changes: 5 additions & 0 deletions packages/taro-mini-runner/src/config/browser_list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default [
'last 3 versions',
'Android >= 4.1',
'ios >= 8'
]
7 changes: 7 additions & 0 deletions packages/taro-mini-runner/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
OUTPUT_DIR: 'dist',
SOURCE_DIR: 'src',
TEMP_DIR: '.temp',
NPM_DIR: 'npm',
ENTRY: 'app'
}
21 changes: 21 additions & 0 deletions packages/taro-mini-runner/src/config/manifest.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"package": "com.application.demo",
"name": "TaroQuickApp",
"versionName": "1.0.0",
"versionCode": "1",
"minPlatformVersion": "101",
"features": [
{ "name": "system.prompt" },
{ "name": "system.router" },
{ "name": "system.shortcut" },
{ "name": "system.fetch" },
{ "name": "system.storage" },
{ "name": "system.barcode" }
],
"permissions": [
{ "origin": "*" }
],
"config": {
"logLevel": "debug"
}
}
28 changes: 28 additions & 0 deletions packages/taro-mini-runner/src/config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"declaration": false,
"experimentalDecorators": true,
"jsx": "react",
"jsxFactory": "Nerv.createElement",
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": false,
"noUnusedLocals": true,
"outDir": "./dist/",
"preserveConstEnums": true,
"removeComments": false,
"rootDir": ".",
"sourceMap": true,
"strictNullChecks": true,
"target": "es6"
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules"
],
"compileOnSave": false
}
1 change: 1 addition & 0 deletions packages/taro-mini-runner/src/config/uglify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default { }
11 changes: 9 additions & 2 deletions packages/taro-mini-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,30 @@ export default function build (config: IBuildConfig) {
const { babel } = compilePlugins
const webpackConfig = {
mode: config.isWatch ? 'development' : 'production',
devtool: "inline-source-map",
entry: config.entry,
output: {
filename: '[name].js',
publicPath: '/',
path: config.outputDir,
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
module: {
rules: [
{
test: /\.(tsx?|jsx?)$/,
include: /src/,
exclude: /node_modules/,
use: [{
loader: path.resolve(__dirname, './loaders/fileParseLoader'),
options: {
babel,
constantsReplaceList: config.constantsReplaceList
designWidth: config.designWidth,
deviceRatio: config.deviceRatio,
buildAdapter: config.buildAdapter,
constantsReplaceList: config.constantsReplaceList,
fileTypeMap: MiniPlugin.getTaroFileTypeMap()
}
}, {
loader: path.resolve(__dirname, './loaders/wxTransformerLoader'),
Expand Down
Loading

0 comments on commit 961e2f6

Please sign in to comment.