sorrycc / roadhog Goto Github PK
View Code? Open in Web Editor NEW🐷 Cli tool for creating react apps, configurable version of create-react-app.
🐷 Cli tool for creating react apps, configurable version of create-react-app.
用之前的方案是可以设置:
webpackConfig.postcss.push(pxtorem({
rootValue: 100,
propWhiteList: [],
}));
现在用roadhog怎么配置?
需考虑 Intellij IDEA 编辑器的支持。
pure function component 时不用手动 import react, https://github.com/vslinko/babel-plugin-react-require
支持 这里 JSON 格式的配置。
{
"disableCSSModules": true,
"autoprefixer": {
"browsers": [
"last 4 versions",
"Firefox ESR",
"> 1%",
"ie >= 8",
"iOS >= 8",
"Android >= 4"
]
},
aa: "a"
}
必须完全是json标准格式,key必须要用双引号包裹,value如果是有字符串类型也必须用双引号包裹。
我将一些项目的通用代码抽出来,用npm pack打包成本地包,由于代码都是jsx+es6的,现在都是pack前用babel编译,这样其它项目使用的时候看到的是es5的代码。如果不用 babel编译后打包,会提示"SyntaxError: Unexpected token"的错误。
能不能类似src,我们指定其它几个node-modules目录下的js也需要babel编译?
新建了一个测试文件
./test/users-test.js
代码如下
import expect from 'expect';
import users from '../src/models/users';
describe('reducers', () => {
describe('reducer', () => {
it('it should save', () => {
expect(users.reducers['save']({}, { payload: { data:[],total:1,page:1 }})).toEqual({list:[],total:1,page:1});
});
})
});
出现如下错误, 请问babel-polyfill 要如何配置
$ roadhog test
/private/tmp/dva-example-user-dashboard/src/utils/request.js:34
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(url, options) {
代码按主框架和业务模块分开打包,使用时按需加载,是否可行?
{
"entry": "src/index.js",
"disableCSSModules": false,
"autoprefixer": null,
"proxy": null,
"extraBabelPlugins": [
"transform-runtime",
["import", { "libraryName": "antd-mobile", "style": true }]
],
"env": {
"development": {
"extraBabelPlugins": [
"dva-hmr"
]
}
}
}
error:
Error in ./src/index.js
Module build failed: ReferenceError: Unknown plugin "import" specified in "base" at 2, attempted to resolve relative to "/Users/macpro/develop/jaway/smartdrive/track/src"
at Array.map (native)
@ multi index
@pigcan
提供中间件或其他方式,让使用 node 的开发模式更容易整合 roadhog 。
传给 DefinePlugin,考虑用 dotenv。
未采用roadhog时使用:
webpackConfig.postcss.push(pxtorem({
rootValue: 100,
propWhiteList: [],
}));
能够正确处理antd-mobile和自己css文件中的单位
现在使用roadhog无法处理antd-mobile,但能够处理自己的css文件:
let postcss = webpackConfig.postcss();
postcss.push(pxtorem({
rootValue: 100,
propWhiteList: [],
}));
webpackConfig.postcss = function () {
return postcss;
};
所以会在支持的同时给予 WARN 警告。
facebook/create-react-app#1247
Then, remove roadhog server --no-open
。
"multipage": true
时使用 CommonsChunkPlugin 提取公用的 common.js 。
{
"disableCSSModules": true,
"less": true,
"autoprefixer": {
"browsers": [
"last 4 versions",
"Firefox ESR",
"> 1%",
"ie >= 8",
"iOS >= 8",
"Android >= 4"
]
}
}
.box {
background: red;
}
import './index.html'
import './index.less'
import React, {Component} from 'react'
import ReactDOM from 'react-dom'
class App extends Component {
componentDidMount() {
}
render() {
return (
<div className="box">
测试
</div>
)
}
}
ReactDOM.render( <App />, document.getElementById('root'))
@ start /Users/MacHewleet/Workspace/SAW_S/testtest
roadhog server
/Users/MacHewleet/Workspace/SAW_S/testtest/node_modules/roadhog/bin/roadhog.js:9
const [major, minor] = nodeVersion.split('.');
^
SyntaxError: Unexpected token [
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:430:10)
at startup (node.js:141:
方便分发.
支持自定义打包命名规则和位置
用于存放 favicon.ico, iconfont 等。
基于 mocha 或 jest 。
开 tab 时查询是否已存在这个特性只对 mac 有效,基于 applescript 实现的,https://github.com/facebookincubator/create-react-app/blob/master/packages/react-dev-utils/openChrome.applescript 。
在 window 或 ubuntu 下每次都会新开,有点麻烦,提供参数禁用掉。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.