Skip to content

Commit e293cc8

Browse files
committed
init
1 parent e0b8b3d commit e293cc8

Some content is hidden

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

51 files changed

+7245
-0
lines changed

.babelrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
["es2015", { "modules": false }],
4+
"stage-2"
5+
],
6+
"plugins": [
7+
"transform-runtime",
8+
"lodash"
9+
],
10+
"comments": false
11+
}

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 4
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[*.{css,less,json,yml}]
11+
indent_size = 2

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public/*.js
2+
build/*.js
3+
src/libs/pinyin/*.js

.eslintrc.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
module.exports = {
2+
root: true,
3+
parser: 'babel-eslint',
4+
parserOptions: {
5+
ecmaVersion: 6,
6+
sourceType: 'module'
7+
},
8+
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
9+
extends: [
10+
'eslint-config-airbnb',
11+
'standard',
12+
],
13+
// required to lint *.vue files
14+
plugins: [
15+
'html'
16+
],
17+
settings: {
18+
"html/html-extensions": [".html", ".vue"]
19+
},
20+
env: {
21+
'browser': true,
22+
'node': true
23+
},
24+
globals: {
25+
'_': true,
26+
},
27+
// add your custom rules here
28+
rules: {
29+
'arrow-parens': 0,
30+
'generator-star-spacing': 0,
31+
'operator-linebreak': ["error", "before"],
32+
'eol-last': 0,
33+
'global-require': 0,
34+
'linebreak-style': 0,
35+
'semi': ["error", "never"],
36+
'no-underscore-dangle': 0,
37+
'space-before-function-paren': [0, "always"],
38+
'comma-dangle': ['error', 'ignore'],
39+
"keyword-spacing": 0,
40+
'indent': [2, 4, { "SwitchCase": 1 }],
41+
'no-new': 0,
42+
'no-console': 0,
43+
'no-unused-expressions': ["error", { "allowShortCircuit": true, "allowTernary": true }],
44+
'no-param-reassign': ["error", { "props": false }],
45+
'no-plusplus': ["error", { "allowForLoopAfterthoughts": true }],
46+
// http://eslint.org/docs/rules/no-restricted-properties
47+
'no-restricted-properties': 0,
48+
'no-bitwise': ["error", { "allow": ["&", "|"] }],
49+
50+
// es6
51+
'no-confusing-arrow': ["error", {"allowParens": true}],
52+
53+
// import
54+
'import/no-unresolved': 0,
55+
'import/extensions': [2, 'never', { "less": "always", "css": "always","jpg": "always", "png": "always" }],
56+
'import/first': 0,
57+
'import/no-dynamic-require': 0,
58+
'import/no-extraneous-dependencies': 0,
59+
// allow debugger during development
60+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
61+
}
62+
}

.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
optional=false
2+
color="always"

.postcssrc.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = ctx => ({
2+
map: ctx.env !== 'development',
3+
plugins: {
4+
autoprefixer: {
5+
browsers: ['last 2 versions']
6+
}
7+
}
8+
})

.stylelintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
public
3+
src/element
4+
src/less/icons.less

.stylelintrc.js

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
module.exports ={
2+
rules: {
3+
// color
4+
'color-named': 'never',
5+
'color-hex-length': 'short',
6+
'color-no-invalid-hex': true,
7+
// font
8+
'font-family-no-duplicate-names': true,
9+
// font-weight
10+
'font-weight-notation': "numeric",
11+
// number
12+
'number-leading-zero': 'never',
13+
'number-no-trailing-zeros': true,
14+
// string
15+
'string-quotes': "double",
16+
'string-no-newline': true,
17+
// length
18+
'length-zero-no-unit': true,
19+
// unit
20+
'unit-case': "lower",
21+
'unit-no-unknown': true,
22+
// value
23+
'value-keyword-case': "lower",
24+
'value-no-vendor-prefix': true,
25+
'shorthand-property-no-redundant-values': true,
26+
// property
27+
'property-case': "lower",
28+
'property-no-unknown': true,
29+
// declaration
30+
'declaration-block-no-duplicate-properties': [true, { ignore: ["consecutive-duplicates-with-different-values"] }],
31+
'declaration-block-single-line-max-declarations': 1,
32+
// 'declaration-block-trailing-semicolon': "never", 省略最后一条属性值后面的分号
33+
'declaration-colon-space-after': "always",
34+
'declaration-colon-space-before': "never",
35+
// selector
36+
'selector-max-compound-selectors': 3,
37+
'selector-attribute-quotes': "always",
38+
'selector-pseudo-class-case': "lower",
39+
'selector-pseudo-element-colon-notation': "double",
40+
'selector-type-no-unknown': true,
41+
'selector-max-empty-lines': 0,
42+
'selector-list-comma-space-after': "always-single-line",
43+
'selector-list-comma-space-before': "never",
44+
'selector-list-comma-newline-after': "always-multi-line",
45+
// block
46+
'block-opening-brace-space-before': "always",
47+
'block-opening-brace-newline-after': "always-multi-line",
48+
'block-closing-brace-newline-before': "always-multi-line",
49+
// rule
50+
'rule-empty-line-before': [
51+
"never-multi-line",
52+
{
53+
"except": [
54+
"after-rule",
55+
"after-single-line-comment",
56+
"first-nested",
57+
"inside-block-and-after-rule"
58+
],
59+
"ignore": ["after-comment", "inside-block"]
60+
}
61+
],
62+
'at-rule-no-vendor-prefix': true,
63+
// Sheet
64+
'indentation': 2,
65+
'max-empty-lines': 2,
66+
'max-nesting-depth': 3,
67+
'no-extra-semicolons': true,
68+
// function
69+
'function-calc-no-unspaced-operator': true,
70+
// 'function-comma-space-after': "never",
71+
'function-comma-space-before': "never",
72+
'function-name-case': "lower",
73+
'function-url-quotes': "always",
74+
}
75+
}

.vscode/settings.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// 将设置放入此文件中以覆盖默认值和用户设置。
2+
{
3+
"editor.wordWrap": "on",
4+
"editor.wrappingIndent": "indent",
5+
"editor.minimap.enabled": true,
6+
"editor.dragAndDrop": true,
7+
"files.associations": {
8+
"*.vue": "vue"
9+
},
10+
"emmet.syntaxProfiles": {
11+
"vue-html": "html",
12+
"vue": "html"
13+
},
14+
"files.eol": "\n",
15+
"files.trimTrailingWhitespace": true,
16+
"files.insertFinalNewline": true,
17+
"eslint.autoFixOnSave": true,
18+
"eslint.validate": [
19+
"javascript",
20+
"javascriptreact",
21+
"vue",
22+
"html"
23+
],
24+
"editor.formatOnSave": false,
25+
"editor.detectIndentation": false,
26+
"html.format.extraLiners": "",
27+
"html.format.endWithNewline": true,
28+
"html.format.indentInnerHtml": true,
29+
"vsicons.dontShowNewVersionMessage": true,
30+
"vsicons.projectDetection.autoReload": true,
31+
"vsicons.presets.angular": false,
32+
"less.lint.zeroUnits": "error",
33+
"vetur.validation.template": false,
34+
"vetur.format.html.wrap_attributes": "force-aligned",
35+
"vetur.format.js.InsertSpaceBeforeFunctionParenthesis": true,
36+
"beautify.tabSize": 2,
37+
"beautify.options": {},
38+
"[css]": {
39+
"editor.insertSpaces": true,
40+
"editor.tabSize": 2
41+
},
42+
"[less]": {
43+
"editor.insertSpaces": true,
44+
"editor.tabSize": 2
45+
}
46+
}

build/build.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
process.env.NODE_ENV = 'production'
2+
3+
const webpack = require('webpack')
4+
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
5+
const conf = require('./webpack.prod.conf')
6+
const clear = require('./clear')
7+
8+
conf.plugins.push(new BundleAnalyzerPlugin())
9+
10+
webpack(conf, (err, stats) => {
11+
clear.stop()
12+
if (err) throw err
13+
process.stdout.write(stats.toString({
14+
colors: true,
15+
modules: false,
16+
children: false,
17+
chunks: false,
18+
chunkModules: false
19+
}) + '\n')
20+
})

build/clear.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require('shelljs/global')
2+
const ora = require('ora')
3+
4+
const spinner = ora('building for production...')
5+
spinner.start()
6+
7+
rm('-rf', 'public')
8+
mkdir('public')
9+
10+
// cp('-R', 'src', conf.output.path)
11+
12+
module.exports = spinner

build/config.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
proxy: false, // 配置代理
3+
devPort: 4000, // 开发端口
4+
distDir: 'public/', // 打包输出目录
5+
localPublicPath: 'http://localhost:4000/resources/', // 本地
6+
remotePublicPath: '//cdn.easypm.cn/pub/', // 远程
7+
apiRoot: '/api', // api root path
8+
uploadUrl: '/upload', // apiRoot + uploadUrl
9+
uploadDir: '../upload/', // 文件保存目录
10+
pages: [{ // src/pages 目录下多页面配置
11+
title: '测试', // 页面标题
12+
name: 'one', // 页面名称与 js 名称一致
13+
chunks: ['common', 'one']
14+
// output: 'one.jsp' // 打包输出文件
15+
}]
16+
}

build/deployer.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require('shelljs/global')
2+
const path = require('path')
3+
const config = require('./config')
4+
/**
5+
* 复制前端打包文件到 java 对应目录
6+
*/
7+
8+
// 目标路径
9+
const prjPath = path.join(__dirname, '..')
10+
const sourceDir = path.join(prjPath, '../resources/static/resources')
11+
const pagePath = path.join(prjPath, '../webapp/WEB-INF/views/pages/platform/platform_pc.jsp')
12+
13+
// 原始路径
14+
const distDir = path.join(prjPath, config.distDir)
15+
16+
cp('-R', distDir + '/!page', sourceDir)

build/devClient.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require('eventsource-polyfill')
2+
const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
3+
4+
hotClient.subscribe(event => {
5+
if (event.action === 'reload') {
6+
window.location.reload()
7+
}
8+
})

build/devMiddleware.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const webpack = require('webpack')
2+
const config = require('./webpack.dev.conf')
3+
4+
module.exports = app => {
5+
const compiler = webpack(config)
6+
const devMiddleware = require('webpack-dev-middleware')(compiler, {
7+
publicPath: config.output.publicPath,
8+
noInfo: true,
9+
stats: {
10+
colors: true,
11+
chunks: false
12+
}
13+
})
14+
const hotMiddleware = require('webpack-hot-middleware')(compiler)
15+
16+
// force page reload when html-webpack-plugin template changes
17+
compiler.plugin('compilation', compilation => {
18+
compilation.plugin('html-webpack-plugin-after-emit', (data, cb) => {
19+
hotMiddleware.publish({ action: 'reload' })
20+
cb()
21+
})
22+
})
23+
24+
app.use(devMiddleware)
25+
app.use(hotMiddleware)
26+
}

build/devRouter.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const router = require('express').Router()
2+
const config = require('./config')
3+
4+
const pages = config.pages
5+
6+
router.get('/', (req, res, next) => {
7+
res.render('index', { pages })
8+
})
9+
10+
pages.forEach(({ name, title, chunks }) => {
11+
router.get('/' + name, (req, res, next) => {
12+
res.render(name + '/index', {
13+
title: title,
14+
chunks: chunks,
15+
devMode: true,
16+
})
17+
})
18+
})
19+
20+
module.exports = router

0 commit comments

Comments
 (0)