Skip to content

Commit

Permalink
feat: ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
huruji committed Nov 22, 2020
1 parent c8ebd9c commit 421c46d
Show file tree
Hide file tree
Showing 21 changed files with 7,694 additions and 11 deletions.
152 changes: 152 additions & 0 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@babel/preset-env": "^7.4.4",
"@babel/preset-typescript": "^7.3.3",
"@babel/runtime": "^7.5.5",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.2",
"add-server-client-script-webpack-plugin": "^1.0.2",
"assign-deep": "^1.0.0",
"author-webpack-plugin": "^1.0.1",
Expand All @@ -56,6 +57,7 @@
"es5-imcompatible-versions": "^0.1.57",
"escape-string-regexp": "^2.0.0",
"extract-css-chunks-webpack-plugin": "^4.7.5",
"file-loader": "^6.1.1",
"get-port": "^5.0.0",
"gh-clone": "^2.0.1",
"git-clone-repo": "^1.0.0",
Expand All @@ -81,6 +83,7 @@
"portfinder": "^1.0.20",
"postcss-loader": "^3.0.0",
"progress-bar-webpack-plugin": "^1.12.1",
"react-refresh": "^0.8.3",
"replace-url-html-webpack-plugin": "^1.0.3",
"resolve-url-loader": "^3.1.0",
"saso-log": "^2.0.2",
Expand Down
19 changes: 10 additions & 9 deletions packages/cli/src/compiler/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import WebpackChain from 'webpack-chain'
import * as fs from 'fs'
import * as path from 'path'
import webpack from 'webpack'

import Hook from './Hook'
import { SasoCompilerConfig } from '../typings/compiler'
import WebpackChain from 'webpack-chain'
import WebpackDevServer from 'webpack-dev-server'
import createWebpackChain from './utils/createWebpackChain'
import getConfig from './utils/getConfig'
import logger from 'saso-log'
import portfinder from 'portfinder'
import Hook from './Hook'
import pick from './utils/pick'
import getConfig from './utils/getConfig'
import createWebpackChain from './utils/createWebpackChain'
import { SasoCompilerConfig } from '../typings/compiler'
import portfinder from 'portfinder'
import webpack from 'webpack'

class Compiler {
config: SasoCompilerConfig
Expand Down Expand Up @@ -132,7 +133,7 @@ class Compiler {
resolve: require.resolve('../plugins/vue-plugin')
},
{
resolve: require.resolve('../plugins/css-plugin')
resolve: require.resolve('../plugins/css-plugin/index2')
},
{
resolve: require.resolve('../plugins/img-plugin')
Expand Down Expand Up @@ -210,7 +211,7 @@ class Compiler {

handleCliOpts(opt: SasoCliOpt): void {
this.config = {}
const cliOpts = [ 'analyzer', 'clear', 'configFile', 'debug', 'dev', 'entry', 'port', 'prod', 'watch', 'minify' ]
const cliOpts = [ 'analyzer', 'clear', 'configFile', 'debug', 'dev', 'entry', 'port', 'prod', 'watch', 'minify', 'typescriptCompiler' ]
// eslint-disable-next-line prefer-spread
const results = pick.apply(null, [ opt ].concat(cliOpts))
Object.assign(this.config, results)
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/compiler/utils/getConfig.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { cosmiconfigSync } from 'cosmiconfig'
import * as path from 'path'
import defaultConfig from './defaultConfig'

import assign from 'assign-deep'
import { cosmiconfigSync } from 'cosmiconfig'
import defaultConfig from './defaultConfig'

export default (cliConfig): SasoConfig => {
let config = defaultConfig
const explorer = cosmiconfigSync('saso')
let result
if (cliConfig.configFile) result = explorer.load(cliConfig.configFile)
else result = explorer.search()
console.log('result')
console.log(result)
if (result && result.config) {
config = assign(config, result.config)
}
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/plugins/js-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const plugin: SasoPlugin = {
cacheDirectory: true
})
.end()
console.log('typescriptCompiler')
console.log(typescriptCompiler)

if (typescriptCompiler === 'typescript') {
c.module
.rule('compile ts')
Expand Down
10 changes: 10 additions & 0 deletions packages/template-ts-react-mobx-lite/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
>1%

last 2 Chrome major versions
last 2 Firefox major versions
last 2 Edge major versions
last 2 Safari major versions
ie 11
last 3 Android major versions
last 3 ChromeAndroid major versions
last 2 iOS major versions
15 changes: 15 additions & 0 deletions packages/template-ts-react-mobx-lite/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions packages/template-ts-react-mobx-lite/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules

postcss.config.js
21 changes: 21 additions & 0 deletions packages/template-ts-react-mobx-lite/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"root": true,
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"plugins": [
"@typescript-eslint"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"@typescript-eslint/explicit-member-accessibility": ["off"],
"@typescript-eslint/explicit-function-return-type": ["off"],
"@typescript-eslint/no-parameter-properties": ["off"]
}
}
Loading

0 comments on commit 421c46d

Please sign in to comment.