Skip to content

Commit 0f3d20b

Browse files
author
Damian Dulisz
committed
Refactor docs
1 parent 751dddf commit 0f3d20b

File tree

90 files changed

+2305
-1717
lines changed

Some content is hidden

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

90 files changed

+2305
-1717
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"presets": ["es2015", "stage-2"],
3-
"plugins": ["transform-runtime", "transform-vue-jsx"],
3+
"plugins": ["transform-vue-jsx"],
44
"comments": false
55
}

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
src/prism.js
2+
config/*.js
3+
*.pug

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ module.exports = {
44
extends: [
55
'standard'
66
],
7+
parser: 'babel-eslint',
8+
parserOptions: {
9+
sourceType: 'module'
10+
},
711
// required to lint *.vue files
812
plugins: ['html'],
913
// add your custom rules here

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 Monterail
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

build/build.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// https://github.com/shelljs/shelljs
2+
require('./check-versions')()
23
require('shelljs/global')
34
env.NODE_ENV = 'production'
45

@@ -17,11 +18,6 @@ console.log(
1718
var spinner = ora('building for production...')
1819
spinner.start()
1920

20-
var assetsPath = path.join(config.docs.assetsRoot, config.docs.assetsSubDirectory)
21-
rm('-rf', assetsPath)
22-
mkdir('-p', assetsPath)
23-
cp('-R', 'static/', assetsPath)
24-
2521
webpack(webpackConfig, function (err, stats) {
2622
spinner.stop()
2723
if (err) throw err

build/check-versions.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
var semver = require('semver')
2+
var chalk = require('chalk')
3+
var packageConfig = require('../package.json')
4+
var exec = function (cmd) {
5+
return require('child_process')
6+
.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-server.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
require('./check-versions')()
2+
var config = require('../config')
3+
if (!process.env.NODE_ENV) process.env.NODE_ENV = config.dev.env
14
var path = require('path')
25
var express = require('express')
36
var webpack = require('webpack')
4-
var config = require('../config')
7+
var opn = require('opn')
58
var proxyMiddleware = require('http-proxy-middleware')
69
var webpackConfig = process.env.NODE_ENV === 'testing'
7-
? require('./webpack.docs.conf')
10+
? require('./webpack.prod.conf')
811
: require('./webpack.dev.conf')
912

1013
// default port where dev server listens for incoming traffic
@@ -53,13 +56,19 @@ app.use(devMiddleware)
5356
app.use(hotMiddleware)
5457

5558
// serve pure static assets
56-
var staticPath = path.posix.join(config.build.assetsPublicPath, config.build.assetsSubDirectory)
59+
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
5760
app.use(staticPath, express.static('./static'))
5861

5962
module.exports = app.listen(port, function (err) {
6063
if (err) {
6164
console.log(err)
6265
return
6366
}
64-
console.log('Listening at http://localhost:' + port + '\n')
67+
var uri = 'http://localhost:' + port
68+
console.log('Listening at ' + uri + '\n')
69+
70+
// when env is testing, don't need open it
71+
if (process.env.NODE_ENV !== 'testing') {
72+
opn(uri)
73+
}
6574
})

build/utils.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ var config = require('../config')
33
var ExtractTextPlugin = require('extract-text-webpack-plugin')
44

55
exports.assetsPath = function (_path) {
6-
return path.posix.join(config.build.assetsSubDirectory, _path)
6+
var assetsSubDirectory = process.env.NODE_ENV === 'production'
7+
? config.docs.assetsSubDirectory
8+
: config.dev.assetsSubDirectory
9+
return path.posix.join(assetsSubDirectory, _path)
710
}
811

912
exports.cssLoaders = function (options) {
@@ -22,14 +25,16 @@ exports.cssLoaders = function (options) {
2225
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
2326
}).join('!')
2427

28+
// Extract CSS when that option is specified
29+
// (which is the case during production docs)
2530
if (options.extract) {
2631
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader)
2732
} else {
2833
return ['vue-style-loader', sourceLoader].join('!')
2934
}
3035
}
3136

32-
// http://vuejs.github.io/vue-loader/configurations/extract-css.html
37+
// http://vuejs.github.io/vue-loader/en/configurations/extract-css.html
3338
return {
3439
css: generateLoaders(['css']),
3540
postcss: generateLoaders(['css']),

build/webpack.base.conf.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,32 @@ var config = require('../config')
33
var utils = require('./utils')
44
var projectRoot = path.resolve(__dirname, '../')
55

6+
var env = process.env.NODE_ENV
7+
// check env & config/index.js to decide weither to enable CSS Sourcemaps for the
8+
// various preprocessor loaders added to vue-loader at the end of this file
9+
var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap)
10+
var cssSourceMapProd = (env === 'production' && config.docs.productionSourceMap)
11+
var useCssSourceMap = cssSourceMapDev || cssSourceMapProd
12+
613
module.exports = {
714
entry: {
815
app: './docs/main.js'
916
},
1017
output: {
11-
path: config.build.assetsRoot,
12-
publicPath: config.build.assetsPublicPath,
18+
path: config.docs.assetsRoot,
19+
publicPath: process.env.NODE_ENV === 'production' ? config.docs.assetsPublicPath : config.dev.assetsPublicPath,
1320
filename: '[name].js'
1421
},
1522
resolve: {
1623
extensions: ['', '.js', '.vue'],
1724
fallback: [path.join(__dirname, '../node_modules')],
1825
alias: {
26+
'vue$': 'vue/dist/vue',
27+
'vue-multiselect': path.resolve(__dirname, '../src/Multiselect'), // for consistent docs
1928
'src': path.resolve(__dirname, '../src'),
20-
'docs': path.resolve(__dirname, '../docs')
29+
'assets': path.resolve(__dirname, '../docs/assets'),
30+
'examples': path.resolve(__dirname, '../docs/partials/examples'),
31+
'components': path.resolve(__dirname, '../src/components')
2132
}
2233
},
2334
resolveLoader: {
@@ -35,7 +46,7 @@ module.exports = {
3546
test: /\.js$/,
3647
loader: 'eslint',
3748
include: projectRoot,
38-
exclude: /node_modules/
49+
exclude: [/node_modules/, /docs\/assets/]
3950
}
4051
],
4152
loaders: [
@@ -54,12 +65,8 @@ module.exports = {
5465
loader: 'json'
5566
},
5667
{
57-
test: /\.html$/,
58-
loader: 'vue-html'
59-
},
60-
{
61-
test: /\.jade$/,
62-
loader: 'jade'
68+
test: /\.pug$/,
69+
loader: 'pug'
6370
},
6471
{
6572
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
@@ -83,6 +90,11 @@ module.exports = {
8390
formatter: require('eslint-friendly-formatter')
8491
},
8592
vue: {
86-
loaders: utils.cssLoaders()
93+
loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }),
94+
postcss: [
95+
require('autoprefixer')({
96+
browsers: ['last 2 versions']
97+
})
98+
]
8799
}
88100
}

build/webpack.bundle.conf.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
const webpack = require('webpack')
2-
const CopyWebpackPlugin = require('copy-webpack-plugin')
32
const base = require('./webpack.base.conf')
43
const config = require('../config')
54

5+
// this is used only for umd browser bundle,
6+
// refer to .babelrc for lib configuration
7+
68
base.entry = {
7-
lib: './src/index.js'
9+
'VueMultiselect': './src/index.js'
810
}
911

1012
base.output = {
1113
path: config.bundle.assetsRoot,
1214
publicPath: config.bundle.assetsPublicPath,
1315
filename: 'vue-multiselect.min.js',
14-
library: 'VueMultiselect',
15-
libraryTarget: 'umd'
16+
libraryTarget: 'umd',
17+
library: 'VueMultiselect'
1618
}
1719

1820
var webpackConfig = Object.assign({}, base)
@@ -26,12 +28,7 @@ webpackConfig.plugins = (webpackConfig.plugins || []).concat([
2628
new webpack.optimize.UglifyJsPlugin({
2729
compress: { warnings: false }
2830
}),
29-
new webpack.optimize.OccurenceOrderPlugin(),
30-
new CopyWebpackPlugin([
31-
{ from: './src/' }
32-
], {
33-
ignore: ['.DS_Store', 'index.js']
34-
})
31+
new webpack.optimize.OccurenceOrderPlugin()
3532
])
3633

3734
module.exports = webpackConfig

0 commit comments

Comments
 (0)