Skip to content

Commit 56bb90d

Browse files
committed
yeoman脚手架搭建的react+webpack的画廊demo
1 parent 5328260 commit 56bb90d

Some content is hidden

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

61 files changed

+7811
-0
lines changed

.babelrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"stage-0",
5+
"react"
6+
]
7+
}

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.eslintrc

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"parser": "babel-eslint",
3+
"plugins": [
4+
"react"
5+
],
6+
"parserOptions": {
7+
"ecmaVersion": 6,
8+
"sourceType": "module",
9+
"ecmaFeatures": {
10+
"jsx": true
11+
}
12+
},
13+
"env": {
14+
"browser": true,
15+
"amd": true,
16+
"es6": true,
17+
"node": true,
18+
"mocha": true
19+
},
20+
"rules": {
21+
"comma-dangle": 1,
22+
"quotes": [ 1, "single" ],
23+
"no-undef": 1,
24+
"global-strict": 0,
25+
"no-extra-semi": 1,
26+
"no-underscore-dangle": 0,
27+
"no-console": 1,
28+
"no-unused-vars": 1,
29+
"no-trailing-spaces": [1, { "skipBlankLines": true }],
30+
"no-unreachable": 1,
31+
"no-alert": 0,
32+
"react/jsx-uses-react": 1,
33+
"react/jsx-uses-vars": 1
34+
}
35+
}

.gitignore

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# node-waf configuration
20+
.lock-wscript
21+
22+
# Compiled binary addons (http://nodejs.org/api/addons.html)
23+
build/Release
24+
25+
# Dependency directory
26+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27+
node_modules
28+
29+
# Bower
30+
bower_components/
31+
32+
# IDE/Editor data
33+
.idea

.yo-rc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"generator-react-webpack": {}
3+
}

cfg/base.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
'use strict';
2+
let path = require('path');
3+
let defaultSettings = require('./defaults');
4+
5+
// Additional npm or bower modules to include in builds
6+
// Add all foreign plugins you may need into this array
7+
// @example:
8+
// let npmBase = path.join(__dirname, '../node_modules');
9+
// let additionalPaths = [ path.join(npmBase, 'react-bootstrap') ];
10+
let additionalPaths = [];
11+
12+
module.exports = {
13+
additionalPaths: additionalPaths,
14+
port: defaultSettings.port,
15+
debug: true,
16+
devtool: 'eval',
17+
output: {
18+
path: path.join(__dirname, '/../dist/assets'),
19+
filename: 'app.js',
20+
publicPath: defaultSettings.publicPath
21+
},
22+
devServer: {
23+
contentBase: './src/',
24+
historyApiFallback: true,
25+
hot: true,
26+
port: defaultSettings.port,
27+
publicPath: defaultSettings.publicPath,
28+
noInfo: false
29+
},
30+
resolve: {
31+
extensions: ['', '.js', '.jsx'],
32+
alias: {
33+
actions: `${defaultSettings.srcPath}/actions/`,
34+
components: `${defaultSettings.srcPath}/components/`,
35+
sources: `${defaultSettings.srcPath}/sources/`,
36+
stores: `${defaultSettings.srcPath}/stores/`,
37+
styles: `${defaultSettings.srcPath}/styles/`,
38+
config: `${defaultSettings.srcPath}/config/` + process.env.REACT_WEBPACK_ENV,
39+
'react/lib/ReactMount': 'react-dom/lib/ReactMount'
40+
}
41+
},
42+
postcss: function () {
43+
return [
44+
require('autoprefixer')({
45+
browsers: ['last 2 versions', 'ie >= 8']
46+
})
47+
];
48+
},
49+
module: {}
50+
};

cfg/defaults.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Function that returns default values.
3+
* Used because Object.assign does a shallow instead of a deep copy.
4+
* Using [].push will add to the base array, so a require will alter
5+
* the base array output.
6+
*/
7+
'use strict';
8+
9+
const path = require('path');
10+
const srcPath = path.join(__dirname, '/../src');
11+
const dfltPort = 8080;
12+
13+
/**
14+
* Get the default modules object for webpack
15+
* @return {Object}
16+
*/
17+
function getDefaultModules() {
18+
return {
19+
preLoaders: [
20+
{
21+
test: /\.(js|jsx)$/,
22+
include: srcPath,
23+
loader: 'eslint-loader'
24+
}
25+
],
26+
loaders: [
27+
{
28+
test: /\.css$/,
29+
loader: 'style-loader!css-loader'
30+
},
31+
{
32+
test: /\.sass/,
33+
loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded&indentedSyntax'
34+
},
35+
{
36+
test: /\.scss/,
37+
loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded'
38+
},
39+
{
40+
test: /\.less/,
41+
loader: 'style-loader!css-loader!less-loader'
42+
},
43+
{
44+
test: /\.styl/,
45+
loader: 'style-loader!css-loader!stylus-loader'
46+
},
47+
{
48+
test: /\.(png|jpg|gif|woff|woff2|eot|ttf|svg)$/,
49+
loader: 'url-loader?limit=8192'
50+
},
51+
{
52+
test: /\.(mp4|ogg|svg)$/,
53+
loader: 'file-loader'
54+
}
55+
]
56+
};
57+
}
58+
59+
module.exports = {
60+
srcPath: srcPath,
61+
publicPath: '/assets/',
62+
port: dfltPort,
63+
getDefaultModules: getDefaultModules
64+
};

cfg/dev.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict';
2+
3+
let path = require('path');
4+
let webpack = require('webpack');
5+
let baseConfig = require('./base');
6+
let defaultSettings = require('./defaults');
7+
let HtmlwebpackPlugin = require('html-webpack-plugin');
8+
let OpenBrowserPlugin = require('open-browser-webpack-plugin');
9+
10+
// Add needed plugins here
11+
let BowerWebpackPlugin = require('bower-webpack-plugin');
12+
13+
let config = Object.assign({}, baseConfig, {
14+
entry: [
15+
'webpack-dev-server/client?http://127.0.0.1:' + defaultSettings.port,
16+
'webpack/hot/only-dev-server',
17+
'./src/index'
18+
],
19+
cache: true,
20+
devtool: 'eval-source-map',
21+
plugins: [
22+
new webpack.HotModuleReplacementPlugin(),
23+
new webpack.NoErrorsPlugin(),
24+
new HtmlwebpackPlugin({
25+
title: 'Webpack-demos',
26+
filename: 'index.html'
27+
}),
28+
new OpenBrowserPlugin({
29+
url: 'http://localhost:8080'
30+
}),
31+
new BowerWebpackPlugin({
32+
searchResolveModulesDirectories: false
33+
})
34+
],
35+
module: defaultSettings.getDefaultModules()
36+
});
37+
38+
// Add needed loaders to the defaults here
39+
config.module.loaders.push({
40+
test: /\.(js|jsx)$/,
41+
loader: 'react-hot!babel-loader',
42+
include: [].concat(
43+
config.additionalPaths,
44+
[ path.join(__dirname, '/../src') ]
45+
)
46+
});
47+
48+
module.exports = config;

cfg/dist.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
3+
let path = require('path');
4+
let webpack = require('webpack');
5+
let baseConfig = require('./base');
6+
let defaultSettings = require('./defaults');
7+
8+
// Add needed plugins here
9+
let BowerWebpackPlugin = require('bower-webpack-plugin');
10+
11+
let config = Object.assign({}, baseConfig, {
12+
entry: path.join(__dirname, '../src/index'),
13+
cache: false,
14+
devtool: 'sourcemap',
15+
plugins: [
16+
new webpack.optimize.DedupePlugin(),
17+
new webpack.DefinePlugin({
18+
'process.env.NODE_ENV': '"production"'
19+
}),
20+
new BowerWebpackPlugin({
21+
searchResolveModulesDirectories: false
22+
}),
23+
new webpack.optimize.UglifyJsPlugin(),
24+
new webpack.optimize.OccurenceOrderPlugin(),
25+
new webpack.optimize.AggressiveMergingPlugin(),
26+
new webpack.NoErrorsPlugin()
27+
],
28+
module: defaultSettings.getDefaultModules()
29+
});
30+
31+
// Add needed loaders to the defaults here
32+
config.module.loaders.push({
33+
test: /\.(js|jsx)$/,
34+
loader: 'babel',
35+
include: [].concat(
36+
config.additionalPaths,
37+
[ path.join(__dirname, '/../src') ]
38+
)
39+
});
40+
41+
module.exports = config;

cfg/test.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use strict';
2+
3+
let path = require('path');
4+
let srcPath = path.join(__dirname, '/../src/');
5+
6+
let baseConfig = require('./base');
7+
8+
// Add needed plugins here
9+
let BowerWebpackPlugin = require('bower-webpack-plugin');
10+
11+
module.exports = {
12+
devtool: 'eval',
13+
module: {
14+
preLoaders: [
15+
{
16+
test: /\.(js|jsx)$/,
17+
loader: 'isparta-instrumenter-loader',
18+
include: [
19+
path.join(__dirname, '/../src')
20+
]
21+
}
22+
],
23+
loaders: [
24+
{
25+
test: /\.(png|jpg|gif|woff|woff2|css|sass|scss|less|styl)$/,
26+
loader: 'null-loader'
27+
},
28+
{
29+
test: /\.(js|jsx)$/,
30+
loader: 'babel-loader',
31+
include: [].concat(
32+
baseConfig.additionalPaths,
33+
[
34+
path.join(__dirname, '/../src'),
35+
path.join(__dirname, '/../test')
36+
]
37+
)
38+
}
39+
]
40+
},
41+
resolve: {
42+
extensions: [ '', '.js', '.jsx' ],
43+
alias: {
44+
actions: srcPath + 'actions/',
45+
helpers: path.join(__dirname, '/../test/helpers'),
46+
components: srcPath + 'components/',
47+
sources: srcPath + 'sources/',
48+
stores: srcPath + 'stores/',
49+
styles: srcPath + 'styles/',
50+
config: srcPath + 'config/' + process.env.REACT_WEBPACK_ENV
51+
}
52+
},
53+
plugins: [
54+
new BowerWebpackPlugin({
55+
searchResolveModulesDirectories: false
56+
})
57+
]
58+
};

dist/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# About the dist folder
2+
After building the dist version of your project, the generated files are stored in this folder. You should keep it under version control.

dist/static/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# static
2+
3+
Files and directories that you put in `static` will be copied to the
4+
`dist/static` directory during the build step. Use it to provide
5+
arbitrary static assets that can be referenced by path in your
6+
application.

dist/static/favicon.ico

4.19 KB
Binary file not shown.

0 commit comments

Comments
 (0)