Skip to content

Commit c7cdc2c

Browse files
author
KevinMint55
committed
完成km-excel基本重构
1 parent 694d0f0 commit c7cdc2c

38 files changed

+11592
-2743
lines changed

.babelrc

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
{
22
"presets": [
3-
["env", {
4-
"modules": false,
5-
"targets": {
6-
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
8+
}
79
}
8-
}],
9-
"stage-2"
10+
]
1011
],
11-
"plugins": ["transform-vue-jsx", "transform-runtime", [
12-
"component",
13-
{
14-
"libraryName": "element-ui",
15-
"styleLibraryName": "theme-chalk"
16-
}
17-
]]
12+
"plugins": [
13+
"@babel/plugin-syntax-dynamic-import",
14+
"@babel/plugin-proposal-class-properties",
15+
[
16+
"component",
17+
{
18+
"libraryName": "element-ui",
19+
"styleLibraryName": "theme-chalk"
20+
}
21+
]
22+
]
1823
}

.eslintrc.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
root: true,
5+
env: {
6+
browser: true,
7+
node: true,
8+
},
9+
extends: [
10+
'plugin:vue/essential',
11+
'airbnb-base',
12+
],
13+
settings: {
14+
'import/resolver': {
15+
webpack: {
16+
config: path.resolve(__dirname, './build/webpack.base.conf.js')
17+
}
18+
}
19+
},
20+
rules: {
21+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
22+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
23+
'linebreak-style': 'off',
24+
'no-mixed-operators': 'off',
25+
'max-len': [1, 300],
26+
'default-case': 0,
27+
'func-names': 0,
28+
'no-param-reassign': 0,
29+
'no-console': 'off',
30+
'no-underscore-dangle': 'off',
31+
'no-lonely-if': 0,
32+
'import/no-extraneous-dependencies': 0,
33+
'global-require': 0,
34+
'prefer-promise-reject-errors': 'off',
35+
"consistent-return": 0,
36+
"no-prototype-builtins": 0,
37+
"no-restricted-globals": 0,
38+
},
39+
parserOptions: {
40+
parser: 'babel-eslint',
41+
},
42+
};

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
.DS_Store
22
node_modules/
3+
/dist/
34
/demo/
45
npm-debug.log*
56
yarn-debug.log*
67
yarn-error.log*
7-
/*.lock
8-
package-lock.json
98

109
# Editor directories and files
1110
.idea
@@ -14,4 +13,3 @@ package-lock.json
1413
*.ntvs*
1514
*.njsproj
1615
*.sln
17-
/.svn

.npmignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
.*
12
build/
2-
node_modules/
3+
node_modules/
4+
demo/

.postcssrc.js

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
module.exports = {
44
"plugins": {
55
"postcss-import": {},
6-
"postcss-url": {},
7-
// to edit target browsers: use "browserslist" field in package.json
86
"autoprefixer": {}
97
}
108
}

README.md

+1-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1 @@
1-
# km-excel
2-
3-
> km-excel
4-
5-
## Build Setup
6-
7-
``` bash
8-
# install dependencies
9-
npm install
10-
11-
# serve with hot reload at localhost:8080
12-
npm run dev
13-
14-
# build for production with minification
15-
npm run build
16-
17-
# build for production and view the bundle analyzer report
18-
npm run build --report
19-
```
20-
21-
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
1+
# km-excel

build/build.js

+23-29
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,34 @@
1-
'use strict'
1+
process.env.NODE_ENV = 'production';
22

3-
process.env.NODE_ENV = 'production'
3+
const webpack = require('webpack');
4+
const chalk = require('chalk');
5+
const ora = require('ora');
6+
const buildWebpackConfig = require('./webpack.prod.conf');
47

5-
const ora = require('ora')
6-
const rm = require('rimraf')
7-
const path = require('path')
8-
const chalk = require('chalk')
9-
const webpack = require('webpack')
10-
const config = require('../config')
11-
const webpackConfig = require('./webpack.prod.conf')
8+
(() => {
9+
const spinner = ora('构建中...');
10+
spinner.start();
1211

13-
const spinner = ora('building for production...')
14-
spinner.start()
15-
16-
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
17-
if (err) throw err
18-
webpack(webpackConfig, (err, stats) => {
19-
spinner.stop()
20-
if (err) throw err
21-
process.stdout.write(stats.toString({
12+
webpack(buildWebpackConfig, (err, status) => {
13+
spinner.stop();
14+
if (err) throw err;
15+
process.stdout.write(status.toString({
2216
colors: true,
2317
modules: false,
24-
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
18+
children: false,
2519
chunks: false,
2620
chunkModules: false
27-
}) + '\n\n')
21+
}) + '\n\n');
2822

29-
if (stats.hasErrors()) {
30-
console.log(chalk.red(' Build failed with errors.\n'))
31-
process.exit(1)
23+
if (status.hasErrors()) {
24+
console.log(chalk.red(' 构建出错!!!\n'));
25+
process.exit(1);
3226
}
3327

34-
console.log(chalk.cyan(' Build complete.\n'))
28+
console.log(chalk.cyan(' 构建成功!!!\n'));
3529
console.log(chalk.yellow(
36-
' Tip: built files are meant to be served over an HTTP server.\n' +
37-
' Opening index.html over file:// won\'t work.\n'
38-
))
39-
})
40-
})
30+
' Tip: 构建的文件需要通过HTTP服务启动.\n' +
31+
' 直接打开 index.html file:// 没有作用.\n'
32+
));
33+
});
34+
})();

build/devServer.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const WebpackDevServer = require('webpack-dev-server');
4+
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
5+
const devWebpackConfig = require('./webpack.dev.conf');
6+
const config = require('../config');
7+
8+
const options = {
9+
publicPath: config.dev.assetsPublicPath,
10+
clientLogLevel: 'warning',
11+
contentBase: false,
12+
historyApiFallback: true,
13+
hot: true,
14+
host: '0.0.0.0',
15+
inline: true,
16+
compress: true,
17+
overlay: { warnings: false, errors: true },
18+
quiet: true,
19+
watchOptions: {
20+
ignored: [/node_modules/],
21+
poll: true,
22+
},
23+
};
24+
25+
const getIPAddress = () => {
26+
const interfaces = require('os').networkInterfaces();
27+
for (let devName in interfaces) {
28+
for (let alias of interfaces[devName]) {
29+
if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
30+
return alias.address;
31+
}
32+
}
33+
}
34+
}
35+
36+
(() => {
37+
const pkgConfig = require(`${path.resolve(__dirname, '../package.json')}`);
38+
const IP = getIPAddress();
39+
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
40+
compilationSuccessInfo: {
41+
messages: [`${pkgConfig.name} 运行地址: http://${IP}:${config.dev.port}`],
42+
},
43+
}));
44+
WebpackDevServer.addDevServerEntrypoints(devWebpackConfig, options);
45+
new WebpackDevServer(webpack(devWebpackConfig), options).listen(config.dev.port, '0.0.0.0', () => { });
46+
})();

build/release.js

+23-29
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,34 @@
1-
'use strict'
1+
process.env.NODE_ENV = 'production';
22

3-
process.env.NODE_ENV = 'production'
3+
const webpack = require('webpack');
4+
const chalk = require('chalk');
5+
const ora = require('ora');
6+
const buildWebpackConfig = require('./webpack.release.conf');
47

5-
const ora = require('ora')
6-
const rm = require('rimraf')
7-
const path = require('path')
8-
const chalk = require('chalk')
9-
const webpack = require('webpack')
10-
const config = require('../config')
11-
const webpackConfig = require('./webpack.release.conf')
8+
(() => {
9+
const spinner = ora('构建中...');
10+
spinner.start();
1211

13-
const spinner = ora('building for production...')
14-
spinner.start()
15-
16-
rm(path.join(config.release.assetsRoot, config.release.assetsSubDirectory), err => {
17-
if (err) throw err
18-
webpack(webpackConfig, (err, stats) => {
19-
spinner.stop()
20-
if (err) throw err
21-
process.stdout.write(stats.toString({
12+
webpack(buildWebpackConfig, (err, status) => {
13+
spinner.stop();
14+
if (err) throw err;
15+
process.stdout.write(status.toString({
2216
colors: true,
2317
modules: false,
24-
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
18+
children: false,
2519
chunks: false,
2620
chunkModules: false
27-
}) + '\n\n')
21+
}) + '\n\n');
2822

29-
if (stats.hasErrors()) {
30-
console.log(chalk.red(' Build failed with errors.\n'))
31-
process.exit(1)
23+
if (status.hasErrors()) {
24+
console.log(chalk.red(' 构建出错!!!\n'));
25+
process.exit(1);
3226
}
3327

34-
console.log(chalk.cyan(' Build complete.\n'))
28+
console.log(chalk.cyan(' 构建成功!!!\n'));
3529
console.log(chalk.yellow(
36-
' Tip: built files are meant to be served over an HTTP server.\n' +
37-
' Opening index.html over file:// won\'t work.\n'
38-
))
39-
})
40-
})
30+
' Tip: 构建的文件需要通过HTTP服务启动.\n' +
31+
' 直接打开 index.html file:// 没有作用.\n'
32+
));
33+
});
34+
})();

0 commit comments

Comments
 (0)