hsx
v0.0.5
JSX、SASS、およびWebpackを使用した静的HTMLサイト(反応なし)。
webpack非常に強力ですwebpack )を使用した静的サイトの構築は、 gulp / gruntよりも明確な利点を提供しますhsx 、新しいプロジェクトの足場のCLIです(テンプレートを参照)。中にあるものの簡単な説明は次のとおりです。
webpack2セットアップstring-domを介してJSXから静的HTMLへpostcss ( autoprefixerとrucksackを使用)imageminを介した画像圧縮webpack-dev-serverを搭載したローカルサーバーMainコンポーネントnpm scriptsを備えたpackage.json $ npm i hsx -g新しいプロジェクトを作成するには:
# using node and npm
# install hsx globally
$ npm install hsx -g
# use the hsx command from the CLI to scaffold a project
# template files are copied to the CWD, unless a path is specified
$ hsx [path]
$ npm i
$ npm run dev次に、ブラウザで:http:// localhost:3000/
JSXをReact.createElementの代わりに、JSXをsd関数呼び出しに変換するためにbabelへのキューに注意してください。
import sd from 'string-dom'
/** @jsx sd */
// create a simple Div component
// children is the HTML wrapped by the element
const Div = ( { children , name } ) => (
< div class = { name } >
{ children }
</ div >
)
// render it to the DOM, with some inner content
document . body . innerHTML += (
< Div name = "site" >
< h1 > hsx </ h1 >
< p > This is inside the Div component! </ p >
</ Div >
) mit。 ©2017 Michael Cavalea