Skip to content
This repository was archived by the owner on Mar 23, 2018. It is now read-only.

Commit b866ee6

Browse files
committed
update from GitLab
1 parent 78d8f8e commit b866ee6

File tree

145 files changed

+4757
-975
lines changed

Some content is hidden

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

145 files changed

+4757
-975
lines changed

.eslintrc.js

+19-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ module.exports = {
44
plugins: [
55
'babel',
66
'flowtype',
7-
'standard'
7+
'standard',
8+
'vue'
89
],
910
extends: [
1011
'standard',
@@ -15,12 +16,23 @@ module.exports = {
1516
},
1617
globals: {
1718
__DEV__: false,
19+
__TEST__: false,
1820
__TESTING__: false,
21+
__PAGES__: false,
1922
__PROD__: false,
2023
__MOCK__: false,
24+
BASE_URL: false,
2125
CONTEXT: false,
2226
IMG_PATH_PREFIX: false,
23-
NON_INDEX_REGEX: false
27+
NON_INDEX_REGEX: false,
28+
OLD_SERVER_PREFIX: false,
29+
SUCCESS: false,
30+
ALERT: false,
31+
CONFIRM: false,
32+
REDIRECT: false,
33+
RELOAD: false,
34+
PROMPT: false,
35+
REMIND: false
2436
},
2537
parserOptions: {
2638
ecmaVersion: 6,
@@ -41,14 +53,16 @@ module.exports = {
4153
'max-nested-callbacks': 2,
4254
'max-params': [2, 5],
4355
'no-mixed-operators': 0,
44-
'standard/no-callback-literal': 0,
56+
'object-curly-spacing': 0,
57+
'prefer-const': [2, {
58+
destructuring: 'all'
59+
}],
4560
'space-before-function-paren': [
4661
2,
4762
{
4863
anonymous: 'always',
4964
named: 'never'
5065
}
51-
],
52-
'object-curly-spacing': 0
66+
]
5367
}
5468
}

.pug-lintrc.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ module.exports = {
3333
requireSpaceAfterCodeOperator: true,
3434
requireSpacesInsideAttributeBrackets: null,
3535
requireSpecificAttributes: [
36-
{
37-
form: 'action'
38-
},
36+
// {
37+
// form: 'action'
38+
// },
3939
// {
4040
// img: 'alt'
4141
// },

build/config/_base.js

+30-10
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ const config = {
4444
chunkModules: false
4545
},
4646
compiler_alias: {
47-
'flow-runtime': 'flow-runtime/dist/flow-runtime',
4847
vue: 'vue/dist/vue.common'
4948
},
5049
compiler_vendor: [
5150
'axios',
5251
'moment',
52+
'qs',
5353
'vue',
5454
'vue-router',
5555
'vuex'
@@ -59,28 +59,48 @@ const config = {
5959
// ------------------------------------
6060
// Environment
6161
// ------------------------------------
62+
63+
const __MOCK__ = !!argv.mock
64+
65+
const __DEV__ = NODE_ENV === 'development'
66+
67+
let NON_INDEX_REGEX = /^(?!.*[/\\](index)\.js).*\.(js|vue)$/.toString()
68+
69+
__DEV__ || (NON_INDEX_REGEX = NON_INDEX_REGEX.replace('index', 'index|test'))
70+
6271
config.globals = {
6372
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
6473
NODE_ENV,
65-
__DEV__: NODE_ENV === 'development',
74+
__DEV__,
6675
__PROD__: NODE_ENV === 'production',
6776
__TEST__: NODE_ENV === 'test',
6877
__TESTING__: NODE_ENV === 'testing',
69-
__MOCK__: !!argv.mock,
70-
CONTEXT: JSON.stringify('/'),
71-
IMG_PATH_PREFIX: JSON.stringify('https://placem.at/'),
72-
NON_INDEX_REGEX: /^(?!.*[/\\](index)\.js).*\.js$/.toString()
78+
__MOCK__,
79+
__PAGES__: !!argv.pages,
80+
BASE_URL: JSON.stringify('/yoga-system'),
81+
CONTEXT: JSON.stringify('/yoga-vision'),
82+
IMG_PATH_PREFIX: JSON.stringify(!__MOCK__ && process.env.IMG_PATH_PREFIX || 'https://placem.at/'),
83+
NON_INDEX_REGEX,
84+
OLD_SERVER_PREFIX: JSON.stringify(process.env.OLD_SERVER_PREFIX || 'http://local.easy-hi.com:8090/yoga-system-res/'),
85+
// result code
86+
SUCCESS: JSON.stringify('0'),
87+
ALERT: JSON.stringify('1'),
88+
CONFIRM: JSON.stringify('2'),
89+
REDIRECT: JSON.stringify('3'),
90+
RELOAD: JSON.stringify('4'),
91+
PROMPT: JSON.stringify('5'),
92+
REMIND: JSON.stringify('10')
7393
}
7494

7595
// ------------------------------------
7696
// Validate Vendor Dependencies
7797
// ------------------------------------
7898
config.compiler_vendor = config.compiler_vendor
7999
.filter(dep => ({...config.pkg.dependencies, ...config.compiler_alias}.hasOwnProperty(dep) ? true : debug(
80-
'Package "' + dep + '" was not found as an npm dependency in package.json; ' +
81-
'it won\'t be included in the webpack vendor bundle.\n' +
82-
'Consider removing it from compiler_vendor in "./config/_base.js"'
83-
)))
100+
'Package "' + dep + '" was not found as an npm dependency in package.json; ' +
101+
'it won\'t be included in the webpack vendor bundle.\n' +
102+
'Consider removing it from compiler_vendor in "./config/_base.js"'
103+
)))
84104

85105
// ------------------------------------
86106
// Utilities

build/webpack/index.js

+53-34
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
import webpack from 'webpack'
2-
import CopyWebpackPlugin from 'copy-webpack-plugin'
2+
import CopyPlugin from 'copy-webpack-plugin'
33
import ExtractTextPlugin from 'extract-text-webpack-plugin'
44
import HtmlWebpackPlugin from 'html-webpack-plugin'
5-
import SWPrecacheWebpackPlugin from 'sw-precache-webpack-plugin'
5+
import SWPrecachePlugin from 'sw-precache-webpack-plugin'
66
import _debug from 'debug'
77
import pug from 'pug'
88

9-
import config, {globals, paths, pkg} from '../config'
10-
import utils, {baseLoaders, cssModuleLoaders, generateLoaders, nodeModules} from './utils'
11-
const {NODE_ENV, __DEV__, __PROD__, __TESTING__, __MOCK__} = globals
9+
import config, {globals, paths} from '../config'
10+
import {
11+
commonCssLoaders,
12+
cssModuleOptions,
13+
baseLoaders,
14+
cssModuleLoaders,
15+
generateLoaders,
16+
nodeModules,
17+
vueCssLoaders
18+
} from './utils'
19+
20+
const {NODE_ENV, __DEV__, __TEST__, __TESTING__, __PROD__, __MOCK__} = globals
1221

1322
const debug = _debug('hi:webpack:config')
1423

@@ -17,7 +26,7 @@ const webpackConfig = {
1726
target: 'web',
1827
resolve: {
1928
modules: [paths.src(), paths.base('packages'), 'node_modules'],
20-
extensions: ['.js', '.styl', '.pug'],
29+
extensions: ['.vue', '.js', '.styl', '.pug'],
2130
enforceExtension: false,
2231
enforceModuleExtension: false,
2332
alias: config.compiler_alias
@@ -39,11 +48,11 @@ const webpackConfig = {
3948
// ------------------------------------
4049
// Entry Points
4150
// ------------------------------------
42-
const APP_ENTRY_PATH = paths.src('index.js')
51+
const APP_ENTRY_PATH = ['regenerator-runtime/runtime', paths.src('index.js')]
4352

4453
webpackConfig.entry = {
4554
app: __DEV__
46-
? [APP_ENTRY_PATH, 'webpack-hot-middleware/client']
55+
? [...APP_ENTRY_PATH, 'webpack-hot-middleware/client']
4756
: APP_ENTRY_PATH,
4857
vendor: config.compiler_vendor
4958
}
@@ -52,40 +61,41 @@ webpackConfig.entry = {
5261
// Bundle Output
5362
// ------------------------------------
5463

64+
const prodEmpty = str => __PROD__ ? '' : str
65+
5566
webpackConfig.output = {
5667
path: paths.dist(),
5768
publicPath: config.compiler_public_path,
58-
filename: `[name].[${config.compiler_hash_type}].js`,
59-
chunkFilename: `[id].[${config.compiler_hash_type}].js`
69+
filename: `${prodEmpty('[name].')}[${config.compiler_hash_type}].js`,
70+
chunkFilename: `${prodEmpty('[id].')}[${config.compiler_hash_type}].js`
6071
}
6172

6273
// ------------------------------------
6374
// Loaders
6475
// ------------------------------------
6576

6677
const sourceMap = !!config.compiler_devtool
67-
const STYLUS_LOADER = 'stylus-loader?paths=node_modules/bootstrap-styl/'
78+
const STYLUS_LOADER = 'stylus-loader'
6879
let appLoader, bootstrapLoader
6980

81+
const extracting = __TEST__ || __PROD__
82+
83+
const IMG_LOADER = __DEV__ ? '' : '!img-loader?minimize&progressive=true'
84+
7085
webpackConfig.module.rules = [
71-
...utils.commonCssLoaders({
86+
...commonCssLoaders({
7287
sourceMap,
73-
exclude: ['styl']
74-
}),
75-
...__TESTING__ ? [{
76-
test: /\.styl$/,
77-
loader: generateLoaders(STYLUS_LOADER, baseLoaders),
78-
exclude: nodeModules
79-
}] : [{
88+
exclude: ['styl', 'stylus']
89+
}), {
8090
test: /[/\\]app\.styl$/,
8191
loader: generateLoaders(STYLUS_LOADER, baseLoaders, {
82-
extract: !__DEV__ && (appLoader = new ExtractTextPlugin('app.[contenthash].css'))
92+
extract: extracting && (appLoader = new ExtractTextPlugin(`${prodEmpty('app.')}[contenthash].css`))
8393
}),
8494
exclude: nodeModules
8595
}, {
8696
test: /[/\\]bootstrap\.styl$/,
8797
loader: generateLoaders(STYLUS_LOADER, baseLoaders, {
88-
extract: !__DEV__ && (bootstrapLoader = new ExtractTextPlugin('bootstrap.[contenthash].css'))
98+
extract: extracting && (bootstrapLoader = new ExtractTextPlugin(`${prodEmpty('bootstrap.')}[contenthash].css`))
8999
}),
90100
exclude: nodeModules
91101
}, {
@@ -96,28 +106,38 @@ webpackConfig.module.rules = [
96106
test: /^(?!.*[/\\](app|bootstrap|theme-\w+)\.styl$).*\.styl$/,
97107
loader: generateLoaders(STYLUS_LOADER, cssModuleLoaders),
98108
exclude: nodeModules
99-
}], {
109+
}, {
100110
test: /\.styl$/,
101111
loader: generateLoaders(STYLUS_LOADER, baseLoaders),
102112
include: nodeModules
113+
}, {
114+
test: /\.stylus$/,
115+
loader: generateLoaders(STYLUS_LOADER, baseLoaders, {style: false})
103116
}, {
104117
test: /\.js$/,
105118
loader: 'babel-loader?cacheDirectory',
106119
exclude: nodeModules
120+
}, {
121+
test: /\.vue$/,
122+
loader: 'vue-loader',
123+
options: {
124+
...vueCssLoaders(),
125+
cssModules: cssModuleOptions
126+
}
107127
}, {
108128
test: /\.pug$/,
109129
loader: `vue-template-es2015-loader!template-file-loader?raw&pretty=${__DEV__}&doctype=html`,
110130
exclude: nodeModules
111131
}, {
112132
test: /\.(png|jpe?g|gif)$/,
113-
loader: 'url-loader?limit=10000&name=[name].[hash].[ext]!img-loader?minimize&progressive=true'
133+
loader: `url-loader?limit=10000&name=${prodEmpty('[name].')}[hash].[ext]${IMG_LOADER}`
114134
},
115135
{
116136
test: /\.(svg|woff2?|eot|ttf)$/,
117137
loader: 'url-loader',
118138
query: {
119139
limit: 10000,
120-
name: '[name].[hash].[ext]'
140+
name: `${prodEmpty('[name].')}[hash].[ext]`
121141
}
122142
}
123143
]
@@ -132,18 +152,18 @@ webpackConfig.plugins = [
132152
new webpack.ContextReplacementPlugin(/\.\/locale$/, null, false, /js$/),
133153
new webpack.DefinePlugin(globals),
134154
new webpack.LoaderOptionsPlugin({
155+
minimize: __PROD__,
135156
stylus: {
136157
default: {
137-
preferPathResolver: 'webpack',
138-
import: [paths.src('styles/_variables.styl')]
158+
import: [paths.src('styles/_variables.styl')],
159+
paths: 'node_modules/bootstrap-styl',
160+
preferPathResolver: 'webpack'
139161
}
140162
}
141163
}),
142164
new HtmlWebpackPlugin({
143165
templateContent: pug.renderFile(paths.src('index.pug'), {
144-
pretty: !config.compiler_html_minify,
145-
title: `${pkg.name} - ${pkg.description}`,
146-
polyfill: !__DEV__
166+
pretty: !config.compiler_html_minify
147167
}),
148168
favicon: paths.src('static/favicon.ico'),
149169
hash: false,
@@ -153,7 +173,7 @@ webpackConfig.plugins = [
153173
minifyJS: config.compiler_html_minify
154174
}
155175
}),
156-
new CopyWebpackPlugin([{
176+
new CopyPlugin([{
157177
from: paths.src('static')
158178
}], {
159179
ignore: ['*.ico', '*.md']
@@ -162,8 +182,7 @@ webpackConfig.plugins = [
162182

163183
// Don't split bundles during testing, since we only want import one bundle
164184
if (!__TESTING__) {
165-
webpackConfig.plugins.push(
166-
new webpack.optimize.CommonsChunkPlugin('vendor'))
185+
webpackConfig.plugins.push(new webpack.optimize.CommonsChunkPlugin('vendor'))
167186
}
168187

169188
if (__DEV__) {
@@ -186,8 +205,8 @@ if (__DEV__) {
186205
comments: false,
187206
sourceMap
188207
}),
189-
new SWPrecacheWebpackPlugin({
190-
cacheId: 'easy-hi',
208+
new SWPrecachePlugin({
209+
cacheId: 'yoga-vision',
191210
filename: 'service-worker.js',
192211
dontCacheBustUrlsMatching: /./,
193212
staticFileGlobsIgnorePatterns: [/index\.html$/, /\.map$/]

0 commit comments

Comments
 (0)