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

script 命令优化 #34

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
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
76 changes: 0 additions & 76 deletions components/Affix/__test__/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,79 +13,3 @@ exports[`render Affix render default 1`] = `
</div>
</div>
`;

exports[`render button render button with child-icon 1`] = `
<div>
<button
class="snake-button snake-button-default snake-button-btn-primary"
type="button"
>
<span>
<svg
class="snake-icon snake-icon-eye-close"
>
<use
xlink:href="#icon-eye-close"
/>
</svg>
闭眼啦
</span>
</button>
</div>
`;

exports[`render button render button with children 1`] = `
<div>
<button
class="snake-button snake-button-default snake-button-btn-primary"
type="button"
>
<span>
确认
</span>
</button>
</div>
`;

exports[`render button render button with type-icon 1`] = `
<div>
<button
class="snake-button snake-button-default snake-button-btn-primary"
type="button"
>
<svg
class="snake-icon snake-icon-eye-close snake-button-icon"
>
<use
xlink:href="#icon-eye-close"
/>
</svg>
<span>
闭眼啦
</span>
</button>
</div>
`;

exports[`render button render default 1`] = `
<div>
<button
class="snake-button snake-button-default snake-button-btn-primary"
type="button"
>
<span />
</button>
</div>
`;

exports[`render text button render only text 1`] = `
<div>
<a
class="snake-button snake-button-text-primary"
>
<span>
文字
</span>
</a>
</div>
`;
18 changes: 9 additions & 9 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>组件库 based hooks</title>
<!--忽略电话号码和 email 识别-->
<meta name="format-detection" content="telephone=no" />
<meta name="format-detection" content="email=no" />
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui">
<link rel="shortcut icon" href="/favicon.ico">
<script src="/build/vendor/vendor.dll.js"></script>
<meta charset="utf-8" />
<title>snake design</title>
<meta
name="viewport"
content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui"
/>
<link rel="shortcut icon" href="/favicon.ico" />
</head>

<body>
<div id="app"></div>
<div id="app"></div>
</body>
</html>
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@
"license": "MIT",
"main": "dist/snake-design.js",
"scripts": {
"start": "yarn build-dll && webpack-dev-server --config webpack/webpack.dev.conf.js --colors",
"start": "bisheng start -c ./site/bisheng.config.js",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anyexinglu 这里的 bisheng 来自 pipixia 这个包~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

soga

"site": "bisheng build -c ./site/bisheng.config.js",
"deploy": "node ./scripts/publishdoc.js",
"build": "tsc -p tsconfig.json && webpack --config webpack/webpack.prod.conf.js",
"build-docs": "webpack --config webpack/docs.config.js",
"build-dll": "webpack --config ./webpack/webpack.dll.config.js",
"test": "jest --config jest.config.js --verbose",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --watch",
"test-update": "jest --updateSnapshot",
"style-fix": "stylelint \"components/**/*.scss\" --syntax scss --fix",
"publish-doc": "node ./scripts/publishdoc.js"
"style-fix": "stylelint \"components/**/*.scss\" --syntax scss --fix"
},
"husky": {
"hooks": {
Expand All @@ -56,7 +55,6 @@
"dependencies": {
"classnames": "^2.2.5",
"normalize.css": "^7.0.0",
"react-spring": "^8.0.18",
"react-transition-group": "^4.0.0",
"warning": "^4.0.3"
},
Expand All @@ -83,6 +81,7 @@
"concurrently": "^3.4.0",
"copy-to-clipboard": "^3.0.8",
"css-loader": "^0.28.7",
"css-split-webpack-plugin": "^0.2.6",
"ejs": "^2.5.7",
"enzyme": "^3.2.0",
"enzyme-adapter-react-16": "^1.1.0",
Expand Down Expand Up @@ -112,6 +111,7 @@
"markdown-it-container": "^2.0.0",
"node-sass": "^4.5.3",
"open-browser-webpack-plugin": "^0.0.5",
"pipixia": "^0.1.0",
"postcss-cssnext": "^3.0.2",
"postcss-loader": "^2.0.6",
"prettier": "^1.16.4",
Expand Down
29 changes: 22 additions & 7 deletions scripts/publishdoc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
var ghpages = require('gh-pages');
var fs = require('fs')
var path = require('path')
var ghpages = require('gh-pages')

ghpages.publish('docsDist', {
repo: '[email protected]:ming-cult/snake-design.git'
}, (err) => {
if (err) {
console.log(err)
/* 将 main-65f5c183.css 转为 ./main-65f5c183.css */
const docsHtmlRoot = path.resolve(__dirname, '../docsDist/index.html')

fs.readFile(docsHtmlRoot, (err, data) => {
const htmlContent = data.toString().replace(/\/main/g, './main')
fs.writeFile(docsHtmlRoot, htmlContent, () => {})
})

/* 发布 */
ghpages.publish(
'docsDist',
{
repo: '[email protected]:ming-cult/snake-design.git'
},
err => {
if (err) {
console.log(err)
}
}
});
)
149 changes: 149 additions & 0 deletions site/bisheng.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
const path = require('path')
const CSSSplitWebpackPlugin = require('css-split-webpack-plugin').default
// const replaceLib = require('antd-tools/lib/replaceLib')
const HtmlWebpackPlugin = require('html-webpack-plugin')

const isDev = process.env.NODE_ENV === 'development'
const usePreact = process.env.REACT_ENV === 'preact'

function alertBabelConfig(rules) {
rules.forEach(rule => {
if (rule.loader && rule.loader === 'babel-loader') {
// if (rule.options.plugins.indexOf(replaceLib) === -1) {
// rule.options.plugins.push(replaceLib)
// }
// eslint-disable-next-line
rule.options.plugins = rule.options.plugins.filter(
plugin => !plugin.indexOf || plugin.indexOf('babel-plugin-add-module-exports') === -1
)
// Add babel-plugin-add-react-displayname
rule.options.plugins.push(require.resolve('babel-plugin-add-react-displayname'))
} else if (rule.use) {
alertBabelConfig(rule.use)
}
})
}

module.exports = {
port: 8001,
hash: true,
// output: path.resolve(__dirname, '../docsDist'),
output: path.resolve(__dirname, '../docsDist'),
// source: {
// components: './components',
// docs: './docs',
// changelog: ['CHANGELOG.zh-CN.md', 'CHANGELOG.en-US.md'],
// },
// theme: './site/theme',
// htmlTemplate: './site/theme/static/template.html',
// htmlTemplate: '../docsDist/index.html',
// htmlTemplate: path.resolve(__dirname, './index.html'),
// themeConfig: {
// categoryOrder: {
// 'Ant Design': 0,
// 原则: 1,
// Principles: 1,
// 视觉: 2,
// Visual: 2,
// 模式: 3,
// Patterns: 3,
// 其他: 6,
// Other: 6,
// Components: 100,
// },
// typeOrder: {
// General: 0,
// Layout: 1,
// Navigation: 2,
// 'Data Entry': 3,
// 'Data Display': 4,
// Feedback: 5,
// Other: 6,
// 通用: 0,
// 布局: 1,
// 导航: 2,
// 数据录入: 3,
// 数据展示: 4,
// 反馈: 5,
// 其他: 6,
// },
// docVersions: {
// '0.9.x': 'http://09x.ant.design',
// '0.10.x': 'http://010x.ant.design',
// '0.11.x': 'http://011x.ant.design',
// '0.12.x': 'http://012x.ant.design',
// '1.x': 'http://1x.ant.design',
// '2.x': 'http://2x.ant.design',
// },
// },
filePathMapper(filePath) {
// if (filePath === '/index.html') {
// return ['/index.html', '/index-cn.html']
// }
// if (filePath.endsWith('/index.html')) {
// return [filePath, filePath.replace(/\/index\.html$/, '-cn/index.html')]
// }
// if (filePath !== '/404.html' && filePath !== '/index-cn.html') {
// return [filePath, filePath.replace(/\.html$/, '-cn.html')]
// }
return filePath
},
doraConfig: {
verbose: true
},
// lessConfig: {
// javascriptEnabled: true
// },
webpackConfig(config) {
config.entry = {
main: ['./docs/app.tsx']
}
// config.output = {
// path: path.resolve(__dirname, '../build'),
// filename: '[name].js',
// publicPath: '/'
// }
// eslint-disable-next-line
config.resolve.alias = {
components: path.join(process.cwd(), 'components'),
types: path.join(process.cwd(), 'types'),
layout: path.join(process.cwd(), 'docs/layout'),
routes: path.join(process.cwd(), 'docs/routes'),
static: path.join(process.cwd(), 'docs/static')
}

// eslint-disable-next-line
// config.externals = {
// 'react-router-dom': 'ReactRouterDOM'
// }

if (isDev) {
// eslint-disable-next-line
config.devtool = 'source-map'
}

alertBabelConfig(config.module.rules)

config.plugins.push(
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(__dirname, '../docs/index.html'),
inject: true,
chunks: ['vendor', 'main']
})
)
config.plugins.push(new CSSSplitWebpackPlugin({ size: 4000 }))

return config
},

devServerConfig: {
public: process.env.DEV_HOST || 'localhost',
disableHostCheck: !!process.env.DEV_HOST
},

htmlTemplateExtraData: {
isDev,
usePreact
}
}
Loading