Skip to content

Commit b06ec3c

Browse files
author
津玮
committed
初始化代码
1 parent 5d9dbc9 commit b06ec3c

23 files changed

+765
-37
lines changed

.babelrc

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

.editorconfig

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

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/*.js
2+
config/*.js

.eslintrc.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// http://eslint.org/docs/user-guide/configuring
2+
3+
module.exports = {
4+
root: true,
5+
parser: 'babel-eslint',
6+
parserOptions: {
7+
sourceType: 'module'
8+
},
9+
env: {
10+
browser: true,
11+
},
12+
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
13+
extends: 'standard',
14+
// required to lint *.vue files
15+
plugins: [
16+
'html'
17+
],
18+
// add your custom rules here
19+
'rules': {
20+
// allow paren-less arrow functions
21+
'arrow-parens': 0,
22+
// allow async-await
23+
'generator-star-spacing': 0,
24+
// allow debugger during development
25+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
26+
}
27+
}

.gitignore

+4-37
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,4 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
6-
# Runtime data
7-
pids
8-
*.pid
9-
*.seed
10-
11-
# Directory for instrumented libs generated by jscoverage/JSCover
12-
lib-cov
13-
14-
# Coverage directory used by tools like istanbul
15-
coverage
16-
17-
# nyc test coverage
18-
.nyc_output
19-
20-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21-
.grunt
22-
23-
# node-waf configuration
24-
.lock-wscript
25-
26-
# Compiled binary addons (http://nodejs.org/api/addons.html)
27-
build/Release
28-
29-
# Dependency directories
30-
node_modules
31-
jspm_packages
32-
33-
# Optional npm cache directory
34-
.npm
35-
36-
# Optional REPL history
37-
.node_repl_history
1+
.DS_Store
2+
node_modules/
3+
dist/
4+
npm-debug.log

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# vue-ueditor
2+
a wrapper of UEditor for vue 2.x
3+
4+
5+
## Description
6+
[UEditor](http://ueditor.baidu.com/website/index.html) 是功能齐全、质量稳定、文档完善的富文本编辑器,可惜它并不能很好的在基于 Vue 的前端项目中使用。于是我写了这个包装组件,使得在基于 Vue 的前端项目中也能很方便的使用 ueditor
7+
8+
## Install
9+
``` npm i vue-ueditor --S ```
10+
11+
(推荐你用 [cnpm](https://npm.taobao.org),这会让你的 npm 包安装速度大幅提升)
12+
13+
## Code
14+
```
15+
import vue-ueditor from 'vue-ueditor'
16+
17+
<vue-ueditor></vue-ueditor>
18+
```
19+
20+
## Lisence
21+
MIT

build/build.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// https://github.com/shelljs/shelljs
2+
require('./check-versions')()
3+
4+
process.env.NODE_ENV = 'production'
5+
6+
var ora = require('ora')
7+
var path = require('path')
8+
var chalk = require('chalk')
9+
var shell = require('shelljs')
10+
var webpack = require('webpack')
11+
var config = require('../config')
12+
var webpackConfig = require('./webpack.prod.conf')
13+
14+
var spinner = ora('building for production...')
15+
spinner.start()
16+
17+
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
18+
shell.rm('-rf', assetsPath)
19+
shell.mkdir('-p', assetsPath)
20+
shell.config.silent = true
21+
shell.cp('-R', 'static/*', assetsPath)
22+
shell.config.silent = false
23+
24+
webpack(webpackConfig, function (err, stats) {
25+
spinner.stop()
26+
if (err) throw err
27+
process.stdout.write(stats.toString({
28+
colors: true,
29+
modules: false,
30+
children: false,
31+
chunks: false,
32+
chunkModules: false
33+
}) + '\n\n')
34+
35+
console.log(chalk.cyan(' Build complete.\n'))
36+
console.log(chalk.yellow(
37+
' Tip: built files are meant to be served over an HTTP server.\n' +
38+
' Opening index.html over file:// won\'t work.\n'
39+
))
40+
})

build/check-versions.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
var chalk = require('chalk')
2+
var semver = require('semver')
3+
var packageConfig = require('../package.json')
4+
5+
function exec (cmd) {
6+
return require('child_process').execSync(cmd).toString().trim()
7+
}
8+
9+
var versionRequirements = [
10+
{
11+
name: 'node',
12+
currentVersion: semver.clean(process.version),
13+
versionRequirement: packageConfig.engines.node
14+
},
15+
{
16+
name: 'npm',
17+
currentVersion: exec('npm --version'),
18+
versionRequirement: packageConfig.engines.npm
19+
}
20+
]
21+
22+
module.exports = function () {
23+
var warnings = []
24+
for (var i = 0; i < versionRequirements.length; i++) {
25+
var mod = versionRequirements[i]
26+
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
27+
warnings.push(mod.name + ': ' +
28+
chalk.red(mod.currentVersion) + ' should be ' +
29+
chalk.green(mod.versionRequirement)
30+
)
31+
}
32+
}
33+
34+
if (warnings.length) {
35+
console.log('')
36+
console.log(chalk.yellow('To use this template, you must update following to modules:'))
37+
console.log()
38+
for (var i = 0; i < warnings.length; i++) {
39+
var warning = warnings[i]
40+
console.log(' ' + warning)
41+
}
42+
console.log()
43+
process.exit(1)
44+
}
45+
}

build/dev-client.js

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

build/dev-server.js

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
require('./check-versions')()
2+
3+
var config = require('../config')
4+
if (!process.env.NODE_ENV) {
5+
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
6+
}
7+
8+
var opn = require('opn')
9+
var path = require('path')
10+
var express = require('express')
11+
var webpack = require('webpack')
12+
var proxyMiddleware = require('http-proxy-middleware')
13+
var webpackConfig = require('./webpack.dev.conf')
14+
15+
// default port where dev server listens for incoming traffic
16+
var port = process.env.PORT || config.dev.port
17+
// automatically open browser, if not set will be false
18+
var autoOpenBrowser = !!config.dev.autoOpenBrowser
19+
// Define HTTP proxies to your custom API backend
20+
// https://github.com/chimurai/http-proxy-middleware
21+
var proxyTable = config.dev.proxyTable
22+
23+
var app = express()
24+
var compiler = webpack(webpackConfig)
25+
26+
var devMiddleware = require('webpack-dev-middleware')(compiler, {
27+
publicPath: webpackConfig.output.publicPath,
28+
quiet: true
29+
})
30+
31+
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
32+
log: () => {}
33+
})
34+
// force page reload when html-webpack-plugin template changes
35+
compiler.plugin('compilation', function (compilation) {
36+
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
37+
hotMiddleware.publish({ action: 'reload' })
38+
cb()
39+
})
40+
})
41+
42+
// proxy api requests
43+
Object.keys(proxyTable).forEach(function (context) {
44+
var options = proxyTable[context]
45+
if (typeof options === 'string') {
46+
options = { target: options }
47+
}
48+
app.use(proxyMiddleware(options.filter || context, options))
49+
})
50+
51+
// handle fallback for HTML5 history API
52+
app.use(require('connect-history-api-fallback')())
53+
54+
// serve webpack bundle output
55+
app.use(devMiddleware)
56+
57+
// enable hot-reload and state-preserving
58+
// compilation error display
59+
app.use(hotMiddleware)
60+
61+
// serve pure static assets
62+
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
63+
app.use(staticPath, express.static('./static'))
64+
65+
var uri = 'http://localhost:' + port
66+
67+
devMiddleware.waitUntilValid(function () {
68+
console.log('> Listening at ' + uri + '\n')
69+
})
70+
71+
module.exports = app.listen(port, function (err) {
72+
if (err) {
73+
console.log(err)
74+
return
75+
}
76+
77+
// when env is testing, don't need open it
78+
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
79+
opn(uri)
80+
}
81+
})

build/utils.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
var path = require('path')
2+
var config = require('../config')
3+
var ExtractTextPlugin = require('extract-text-webpack-plugin')
4+
5+
exports.assetsPath = function (_path) {
6+
var assetsSubDirectory = process.env.NODE_ENV === 'production'
7+
? config.build.assetsSubDirectory
8+
: config.dev.assetsSubDirectory
9+
return path.posix.join(assetsSubDirectory, _path)
10+
}
11+
12+
exports.cssLoaders = function (options) {
13+
options = options || {}
14+
// generate loader string to be used with extract text plugin
15+
function generateLoaders (loaders) {
16+
var sourceLoader = loaders.map(function (loader) {
17+
var extraParamChar
18+
if (/\?/.test(loader)) {
19+
loader = loader.replace(/\?/, '-loader?')
20+
extraParamChar = '&'
21+
} else {
22+
loader = loader + '-loader'
23+
extraParamChar = '?'
24+
}
25+
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
26+
}).join('!')
27+
28+
// Extract CSS when that option is specified
29+
// (which is the case during production build)
30+
if (options.extract) {
31+
return ExtractTextPlugin.extract({
32+
use: sourceLoader,
33+
fallback: 'vue-style-loader'
34+
})
35+
} else {
36+
return ['vue-style-loader', sourceLoader].join('!')
37+
}
38+
}
39+
40+
// http://vuejs.github.io/vue-loader/en/configurations/extract-css.html
41+
return {
42+
css: generateLoaders(['css']),
43+
postcss: generateLoaders(['css']),
44+
less: generateLoaders(['css', 'less']),
45+
sass: generateLoaders(['css', 'sass?indentedSyntax']),
46+
scss: generateLoaders(['css', 'sass']),
47+
stylus: generateLoaders(['css', 'stylus']),
48+
styl: generateLoaders(['css', 'stylus'])
49+
}
50+
}
51+
52+
// Generate loaders for standalone style files (outside of .vue)
53+
exports.styleLoaders = function (options) {
54+
var output = []
55+
var loaders = exports.cssLoaders(options)
56+
for (var extension in loaders) {
57+
var loader = loaders[extension]
58+
output.push({
59+
test: new RegExp('\\.' + extension + '$'),
60+
loader: loader
61+
})
62+
}
63+
return output
64+
}

build/vue-loader.conf.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var utils = require('./utils')
2+
var config = require('../config')
3+
var isProduction = process.env.NODE_ENV === 'production'
4+
5+
module.exports = {
6+
loaders: utils.cssLoaders({
7+
sourceMap: isProduction
8+
? config.build.productionSourceMap
9+
: config.dev.cssSourceMap,
10+
extract: isProduction
11+
}),
12+
postcss: [
13+
require('autoprefixer')({
14+
browsers: ['last 2 versions']
15+
})
16+
]
17+
}

0 commit comments

Comments
 (0)