Skip to content

Commit fbdc8f9

Browse files
集成redux
1 parent 78fe4d7 commit fbdc8f9

16 files changed

+819
-36
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist
2+
node_modules
3+
assert
4+
public

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules
22
dist
33
.vs_code
4-
.DS_Store
4+
.DS_Store

babel.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const presets = [
1212
'@babel/react'
1313
];
1414
const plugins = [
15+
['import', { libraryName: 'antd-mobile', style: 'css' }], // `style: true` 会加载 less 文件
1516
'@babel/plugin-transform-arrow-functions',
1617
'@babel/plugin-transform-block-scoped-functions',
1718
'@babel/plugin-transform-async-to-generator',

build/webpack.config.base.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ const COMMON_0_CSS = new ExtractTextPlugin('common.0.css', {allChunks: true});
1212
const COMMON_1_CSS = new ExtractTextPlugin('common.1.css', {allChunks: true});
1313
const COMMON_0_LESS = new ExtractTextPlugin('app.0.css', {allChunks: true});
1414
const COMMON_1_LESS = new ExtractTextPlugin('app.1.css', {allChunks: true});
15-
1615
const happyThreadPoolLength = os.cpus().length;
17-
1816
const getRealPath = (temPath) => {
1917
return path.resolve(__dirname, temPath);
2018
};
21-
2219
const node_modules = getRealPath('../node_modules');
2320

2421
module.exports = (env = 'development') => {
@@ -148,6 +145,10 @@ module.exports = (env = 'development') => {
148145
// $config: getRealPath('../config/config'),
149146
// }
150147
},
148+
externals: {
149+
'react': 'React',
150+
'react-dom': 'ReactDOM'
151+
},
151152
plugins: [
152153
COMMON_0_CSS,
153154
COMMON_1_CSS,

build/webpack.config.dev.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ const chalk = require('chalk');
44
const config = require('../config/webpackConfig');
55
const webpackBaseConfig = require('./webpack.config.base');
66
const _ = require('lodash');
7+
const CopyWebpackPlugin = require('copy-webpack-plugin');
78
const generateDll = require('../utils/generateDll');
8-
9+
const getRealPath = (temPath) => {
10+
return path.resolve(__dirname, temPath);
11+
};
912
generateDll();
1013

1114
let baseConfig = webpackBaseConfig('development');
@@ -30,6 +33,10 @@ let devPlugins = [
3033
// name: '[name]_library',
3134
manifest: require('../dist/manifest.json'),
3235
}),
36+
new CopyWebpackPlugin([
37+
{ from: getRealPath('../node_modules/react/umd/react.production.min.js'), to: getRealPath('../dist/react.production.min.js') },
38+
{ from: getRealPath('../node_modules/react-dom/umd/react-dom.production.min.js'), to: getRealPath('../dist/react-dom.production.min.js') },
39+
]),
3340
/*eslint-disable*/
3441
new webpack.DefinePlugin({
3542
"process.env.NODE_ENV": JSON.stringify("development"),// 一定要用json.stringify,如果是单引号的'development',不正确,是定义不了process.env.NODE_ENV的

build/webpack.config.prod.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ const merge = require('webpack-merge');
66
const webpackBaseConfig = require('./webpack.config.base');
77
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
88
const CleanWebpackPlugin = require('clean-webpack-plugin');
9+
const CopyWebpackPlugin = require('copy-webpack-plugin');
910
// var CompressionWebpackPlugin = require('compression-webpack-plugin');// 开启gzip压缩
1011
// const config = require('../config/webpackConfig');
1112
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
1213
//获取npm后面的命令
1314
const commandTarget = process.env.npm_lifecycle_event; // npm run start:build 获取的是start:build
1415
let startAnalyzer = _.includes(_.toLower(commandTarget), 'analyzer');
1516
console.log(chalk.yellow(`logging: the project is openning analyzer, the startAnalyzer is ${startAnalyzer}`));
17+
const getRealPath = (temPath) => {
18+
return path.resolve(__dirname, temPath);
19+
};
1620

1721
let plugins = [
1822
new CleanWebpackPlugin(path.resolve(__dirname, '../dist'), {
@@ -45,7 +49,11 @@ let plugins = [
4549
new webpack.optimize.LimitChunkCountPlugin({
4650
maxChunks: 5, // Must be greater than or equal to one
4751
minChunkSize: 1000
48-
}),
52+
}),
53+
new CopyWebpackPlugin([
54+
{ from: getRealPath('../node_modules/react/umd/react.production.min.js'), to: getRealPath('../dist/react.production.min.js') },
55+
{ from: getRealPath('../node_modules/react-dom/umd/react-dom.production.min.js'), to: getRealPath('../dist/react-dom.production.min.js') },
56+
]),
4957
// new CompressionWebpackPlugin(),
5058
// 打包moment.js的中文,防止local全部打包
5159
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/,/zh-cn/),

index.html

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
67
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7-
<title>Document</title>
8+
<meta name="keywords" content="网易云音乐,web app">
9+
<meta itemprop="name" content="网易云音乐">
10+
<meta itemprop="author" content="zhangzhen">
11+
<meta property="og:title" content="网易云音乐">
12+
<title>网易云-webApp</title>
13+
<meta property="og:type" content="website">
14+
<meta property="og:image" content="http://p3.music.126.net/tBTNafgjNnTL1KlZMt7lVA==/18885211718935735.jpg">
15+
<meta property="og:url" content="https://music.163.com/m">
16+
<link rel="shortcut icon" href="http://p3.music.126.net/0ZrFKozxhB6nPQYZl4lsEA==/109951163421145421.png" type="image/x-icon">
17+
<script src="https://as.alipayobjects.com/g/component/fastclick/1.0.6/fastclick.js"></script>
18+
<script>
19+
if ('addEventListener' in document) {
20+
document.addEventListener('DOMContentLoaded', function () {
21+
FastClick.attach(document.body);
22+
}, false);
23+
}
24+
if (!window.Promise) {
25+
document.writeln(
26+
'<script src="https://as.alipayobjects.com/g/component/es6-promise/3.2.2/es6-promise.min.js"' + '>' +
27+
'<' + '/' + 'script>');
28+
}
29+
30+
</script>
831
</head>
32+
933
<body>
1034
<div id="root"></div>
35+
<script src="./react.production.min.js"></script>
36+
<script src="./react-dom.production.min.js"></script>
1137
</body>
38+
1239
</html>

0 commit comments

Comments
 (0)