hsx
v0.0.5
帶有JSX,SASS和WebPack的靜態HTML站點(無反應)。
webpack非常強大webpack )建造靜態站點(WebPack)提供了與gulp / grunt不同優勢hsx是用於腳手架新項目的CLI(請參閱模板)。內部內容的簡要說明如下:
webpack2設置string-dompostcss (帶有autoprefixer和rucksack )imageminwebpack-dev-server驅動的本地服務器Main組件package.json一些有用的npm scripts $ 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/
請注意,提示babel將JSX轉換為sd函數調用,而不是React.createElement 。
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 >
) 麻省理工學院。 ©2017 Michael Cavalea