Skip to content

Commit 7e872b5

Browse files
committed
finish question
1 parent d4de076 commit 7e872b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+233
-194
lines changed

README.md

Lines changed: 0 additions & 19 deletions

build/webpack-config/loaders.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

meta.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
module.exports = {
2+
prompts: {
3+
name: {
4+
type: 'string',
5+
required: true,
6+
message: 'Project name'
7+
},
8+
author: {
9+
type: 'string',
10+
message: 'Author'
11+
},
12+
type: {
13+
type: 'list',
14+
message: 'Which type do you want?',
15+
choices:[{
16+
name: 'Single-Page(no react-router)',
17+
value: 'single',
18+
short: 'Single(No-Router)'
19+
},{
20+
name: 'Multi-Page(with react-router)',
21+
value: 'multi',
22+
short: 'Multi(With-Router)'
23+
}]
24+
},
25+
stateContainer:{
26+
when: function(answers){
27+
return answers.type === 'single'
28+
},
29+
type: 'confirm',
30+
message: 'Do you want to use redux?',
31+
default: false
32+
},
33+
eslint: {
34+
type: 'confirm',
35+
require: true,
36+
message: 'Use linting with ESLint?',
37+
default: true
38+
},
39+
eslintConfig: {
40+
when: 'eslint',
41+
type: 'list',
42+
message: 'Which eslint config would you like to use?',
43+
choices: [{
44+
name: 'Standard (https://github.com/feross/standard)',
45+
value: 'standard',
46+
short: 'Standard'
47+
}, {
48+
name: 'none (configure it yourself)',
49+
value: 'none',
50+
short: 'None'
51+
}]
52+
},
53+
unit: {
54+
type: 'confirm',
55+
require: true,
56+
message: 'Setup unit tests with Karma + Mocha?',
57+
default: true
58+
}
59+
},
60+
filters: {
61+
'.eslintignore': 'eslint',
62+
'.eslintrc.js': 'eslint',
63+
'test/**/*': 'unit'
64+
},
65+
completeMessage: 'To get started:\n\n cd {{destDirName}}\n npm install\n npm run dev'
66+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

template/README.md

Lines changed: 20 additions & 0 deletions
File renamed without changes.
File renamed without changes.

build/base-config/configs.js renamed to template/build/base-config/configs.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const cssnano = require('cssnano');
2-
31
module.exports = {
42
development: {
53
performance: {
@@ -36,20 +34,10 @@ module.exports = {
3634
'react-dom'
3735
],
3836
postcss: [
39-
cssnano({
40-
autoprefixer: {
41-
add: true,
42-
remove: true,
43-
browsers: ['last 2 versions']
44-
},
45-
discardComments: {
46-
removeAll: true
47-
},
48-
discardUnused: false,
49-
mergeIdents: false,
50-
reduceIdents: false,
51-
safe: true,
52-
sourcemap: true
37+
require('autoprefixer')({
38+
add: true,
39+
remove: true,
40+
browsers: ['last 2 versions']
5341
})
5442
]
5543
}

build/base-config/environment.js renamed to template/build/base-config/environment.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ const envConfigs = require('./configs');
33

44
module.exports = {
55
/**
6-
* why? https://fb.me/react-minification ,http://stackoverflow.com/questions/30030031
6+
* why? you can see:
7+
* https://fb.me/react-minification
8+
* http://stackoverflow.com/questions/30030031
79
*/
810
'process.env': {
911
NODE_ENV: JSON.stringify(NODE_ENV)
File renamed without changes.
File renamed without changes.
File renamed without changes.

build/webpack-config/base.js renamed to template/build/webpack-config/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = (paths) => {
2929
output: {
3030
filename: '[name].[hash:8].js',
3131
path: paths.dist(),
32-
publicPath: '/'
32+
publicPath: ''
3333
},
3434
performance: envConfig.performance
3535
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const debug = require('debug')('app:webpack:loaders');
2+
const env = require('../base-config/environment');
3+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
4+
5+
const isDev = env.isDev;
6+
const isProd = env.isProd;
7+
module.exports = () => {
8+
const rules = [{
9+
test: /\.(js|jsx)$/,
10+
exclude: /node_modules/,
11+
use: [{ loader: 'babel-loader' }]
12+
}, {
13+
test: /\.json$/,
14+
use: [{ loader: 'json-loader' }]
15+
}, {
16+
test: /\.(css|less)$/,
17+
use: [
18+
{
19+
loader: 'style-loader'
20+
}, {
21+
loader: 'css-loader',
22+
// use 'options' for ExtractTextPlugin is not effect, so use 'query' to replace 'options'
23+
query: {
24+
minimize: isProd,
25+
sourceMap: !isProd
26+
}
27+
}, {
28+
loader: 'postcss-loader'
29+
}, {
30+
loader: 'less-loader',
31+
options: {
32+
sourceMap: !isProd
33+
}
34+
}
35+
]
36+
}, {
37+
test: /\.(png|jpg)$/,
38+
use: [{
39+
loader: 'url-loader',
40+
options: {
41+
limit: 8192
42+
}
43+
}]
44+
}];
45+
if (!isDev) {
46+
debug('Apply ExtractTextPlugin to CSS loaders.');
47+
rules.filter(rule => rule.use && rule.use.find(loaderObj => /css/.test(loaderObj.loader.split('?')[0])))
48+
.forEach((rule) => {
49+
const first = rule.use[0];
50+
const rest = rule.use.slice(1);
51+
rule.loader = ExtractTextPlugin.extract({ fallbackLoader: first, loader: rest });
52+
delete rule.use;
53+
});
54+
}
55+
return rules;
56+
};

package.json renamed to template/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"author": "likun",
4343
"license": "MIT",
4444
"devDependencies": {
45+
"autoprefixer": "^6.7.6",
4546
"babel-core": "^6.20.0",
4647
"babel-eslint": "^7.1.1",
4748
"babel-loader": "^6.2.9",
@@ -54,7 +55,6 @@
5455
"compression": "^1.6.2",
5556
"connect-history-api-fallback": "^1.3.0",
5657
"css-loader": "^0.26.1",
57-
"cssnano": "^3.10.0",
5858
"debug": "^2.4.5",
5959
"eslint": "^3.12.2",
6060
"eslint-config-airbnb": "^13.0.0",
@@ -63,7 +63,7 @@
6363
"eslint-plugin-jsx-a11y": "2.2.3",
6464
"eslint-plugin-react": "^6.8.0",
6565
"express": "^4.14.0",
66-
"extract-text-webpack-plugin": "2.0.0-beta.4",
66+
"extract-text-webpack-plugin": "^2.1.0",
6767
"file-loader": "^0.9.0",
6868
"fs-extra": "^1.0.0",
6969
"html-webpack-plugin": "^2.24.1",
@@ -75,15 +75,13 @@
7575
"karma-webpack-with-fast-source-maps": "^1.10.0",
7676
"less": "^2.7.1",
7777
"less-loader": "^2.2.3",
78-
"line-debugger": "^0.0.1",
7978
"mocha": "^3.2.0",
8079
"postcss-loader": "^1.2.1",
81-
"redbox-react": "^1.3.3",
8280
"redux-logger": "^2.7.4",
8381
"rimraf": "^2.5.4",
8482
"style-loader": "^0.13.1",
8583
"url-loader": "^0.5.7",
86-
"webpack": "2.2.0-rc.3",
84+
"webpack": "^2.2.1",
8785
"webpack-dev-middleware": "^1.8.4",
8886
"webpack-hot-middleware": "^2.13.2"
8987
},
File renamed without changes.
File renamed without changes.

src/main.js renamed to template/src/main.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,14 @@ const store = createStore(initialState);
1010
// some setup
1111
const MOUNT_NODE = document.getElementById('root');
1212

13-
let render = () => {
13+
const render = () => {
1414
const routes = require('./routes/index').default(store); // !important
1515
ReactDOM.render(
1616
<App store={store} routes={routes} />,
1717
MOUNT_NODE
1818
);
1919
};
2020
if (isDev && module.hot) {
21-
const renderApp = render;
22-
const renderError = (error) => {
23-
const RedBox = require('redbox-react').default; // eslint-disable-line
24-
ReactDOM.render(<RedBox error={error} />, MOUNT_NODE);
25-
};
26-
render = () => {
27-
try {
28-
renderApp();
29-
} catch (error) {
30-
renderError(error);
31-
}
32-
};
3321
module.hot.accept('./routes/index', () => {
3422
ReactDOM.unmountComponentAtNode(MOUNT_NODE);
3523
render();
File renamed without changes.

src/routes/Home/components/HomeView.js renamed to template/src/routes/Home/components/HomeView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export const HomeView = () => (
55
<div>
66
<h4>Welcome!</h4>
77
<img
8-
alt="This is a duck, because Redux!"
9-
className="duck"
8+
alt="A magic!"
9+
className="magic"
1010
src="/images/magic.png"
1111
/>
1212
</div>

src/routes/Home/components/HomeView.less renamed to template/src/routes/Home/components/HomeView.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.duck {
1+
.magic {
22
display: block;
33
width: 120px;
44
margin: 1.5rem auto;
File renamed without changes.

src/routes/increase/components/increaseComponent.js renamed to template/src/routes/increase/components/increaseComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { PropTypes } from 'react';
22

33
export const Increase = props => (
4-
<div style={{ margin: '0 auto' }} >
4+
<div >
55
<h2>Counter: {props.increase}</h2>
66
<button className="btn btn-default" onClick={props.increment}>
77
Increment
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)