Skip to content

Commit b2fd0de

Browse files
committed
Merge branch 'develop'
* develop: remove unnecessary exceptions bump version to 1.2.6 Add JX support (close #1146) Automatically install Dependencies and fix lint errors (#1133) Set `allChunks: true` by default (close #1110) (#1149) airbnb eslint config compatibility with vuex (#1003) Document babel target env configuration (#1144) Revert "remove uneccessary target.browsers (#1004)" (#1083) fix filename of `.eslintignore` (#1136) webpack.conf.js is not needed in jest and e2e (#1135) # Conflicts: # template/test/e2e/custom-assertions/elementCount.js
2 parents c4943a1 + cc89353 commit b2fd0de

21 files changed

+365
-193
lines changed

docs/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- [Project Structure](structure.md)
44
- [Build Commands](commands.md)
5+
- [Babel Configuration](babel.md)
56
- [Linter Configuration](linter.md)
67
- [Pre-Processors](pre-processors.md)
78
- [Handling Static Assets](static.md)

docs/babel.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Babel Configuration
2+
3+
This boilerplate uses [`babel-preset-env`](https://www.npmjs.com/package/babel-preset-env) for configuring babel. You can read more about it here - http://2ality.com/2017/02/babel-preset-env.html.
4+
5+
> A Babel preset that compiles ES2015+ down to ES5 by automatically determining the Babel plugins and polyfills you need based on your targeted browser or runtime environments.
6+
7+
It uses [`browserslist`](https://github.com/ai/browserslist) to parse this information, so we can use any [valid query format supported by `browserslist`](https://github.com/ai/browserslist#queries).
8+
9+
However there is a caveat. `browserslist` recommends defining the target in a common place like `package.json` or in a `.browserslistrc` config file. This allows tools like [`autoprefixer`](https://github.com/postcss/autoprefixer) and [`eslint-plugin-compat`](https://github.com/amilajack/eslint-plugin-compat) to share the config. For this template, `browserslist` is configured in the `package.json`:
10+
11+
```json
12+
{
13+
"...": "...",
14+
"browserslist": [
15+
"> 1%",
16+
"last 2 versions",
17+
"not ie <= 8"
18+
]
19+
}
20+
```
21+
22+
But the latest stable release of `babel-preset-env`, `v1.6.1` does not support loading the config from `package.json`. So the target environment is repeated in `.babelrc`. If you wish to change your target environment, please be sure to update both `package.json` and `.babelrc`. Note that this has been fixed in the beta version([`@babel/[email protected]`](https://github.com/babel/babel/tree/master/packages/babel-preset-env)) and the template will be updated once it is out of beta.

docs/structure.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
├── .babelrc # babel config
3232
├── .editorconfig # indentation, spaces/tabs and similar settings for your editor
3333
├── .eslintrc.js # eslint config
34-
├── .eslintignore.js # eslint ignore rules
34+
├── .eslintignore # eslint ignore rules
3535
├── .gitignore # sensible defaults for gitignore
3636
├── .postcssrc.js # postcss config
3737
├── index.html # index.html template

meta.js

+124-101
Original file line numberDiff line numberDiff line change
@@ -1,146 +1,169 @@
11
const path = require('path');
22
const fs = require('fs');
3-
4-
function sortObject(object) {
5-
// Based on https://github.com/yarnpkg/yarn/blob/v1.3.2/src/config.js#L79-L85
6-
const sortedObject = {};
7-
Object.keys(object).sort().forEach(item => {
8-
sortedObject[item] = object[item];
9-
});
10-
return sortedObject;
11-
}
3+
const {
4+
sortDependencies,
5+
installDependencies,
6+
runLintFix,
7+
printMessage
8+
} = require('./utils')
129

1310
module.exports = {
14-
"helpers": {
15-
"if_or": function (v1, v2, options) {
11+
helpers: {
12+
if_or: function (v1, v2, options) {
1613
if (v1 || v2) {
1714
return options.fn(this);
1815
}
1916

2017
return options.inverse(this);
2118
}
2219
},
23-
"prompts": {
24-
"name": {
25-
"type": "string",
26-
"required": true,
27-
"message": "Project name"
20+
prompts: {
21+
name: {
22+
type: 'string',
23+
required: true,
24+
message: 'Project name'
2825
},
29-
"description": {
30-
"type": "string",
31-
"required": false,
32-
"message": "Project description",
33-
"default": "A Vue.js project"
26+
description: {
27+
type: 'string',
28+
required: false,
29+
message: 'Project description',
30+
default: 'A Vue.js project'
3431
},
35-
"author": {
36-
"type": "string",
37-
"message": "Author"
32+
author: {
33+
type: 'string',
34+
message: 'Author'
3835
},
39-
"build": {
40-
"type": "list",
41-
"message": "Vue build",
42-
"choices": [
36+
build: {
37+
type: 'list',
38+
message: 'Vue build',
39+
choices: [
4340
{
44-
"name": "Runtime + Compiler: recommended for most users",
45-
"value": "standalone",
46-
"short": "standalone"
41+
name: 'Runtime + Compiler: recommended for most users',
42+
value: 'standalone',
43+
short: 'standalone'
4744
},
4845
{
49-
"name": "Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere",
50-
"value": "runtime",
51-
"short": "runtime"
46+
name: 'Runtime-only: about 6KB lighter min+gzip, but templates (or any Vue-specific HTML) are ONLY allowed in .vue files - render functions are required elsewhere',
47+
value: 'runtime',
48+
short: 'runtime'
5249
}
5350
]
5451
},
55-
"router": {
56-
"type": "confirm",
57-
"message": "Install vue-router?"
52+
router: {
53+
type: 'confirm',
54+
message: 'Install vue-router?'
5855
},
59-
"lint": {
60-
"type": "confirm",
61-
"message": "Use ESLint to lint your code?"
56+
lint: {
57+
type: 'confirm',
58+
message: 'Use ESLint to lint your code?'
6259
},
63-
"lintConfig": {
64-
"when": "lint",
65-
"type": "list",
66-
"message": "Pick an ESLint preset",
67-
"choices": [
60+
lintConfig: {
61+
when: 'lint',
62+
type: 'list',
63+
message: 'Pick an ESLint preset',
64+
choices: [
6865
{
69-
"name": "Standard (https://github.com/standard/standard)",
70-
"value": "standard",
71-
"short": "Standard"
66+
name: 'Standard (https://github.com/standard/standard)',
67+
value: 'standard',
68+
short: 'Standard'
7269
},
7370
{
74-
"name": "Airbnb (https://github.com/airbnb/javascript)",
75-
"value": "airbnb",
76-
"short": "Airbnb"
71+
name: 'Airbnb (https://github.com/airbnb/javascript)',
72+
value: 'airbnb',
73+
short: 'Airbnb'
7774
},
7875
{
79-
"name": "none (configure it yourself)",
80-
"value": "none",
81-
"short": "none"
76+
name: 'none (configure it yourself)',
77+
value: 'none',
78+
short: 'none'
8279
}
8380
]
8481
},
85-
"unit": {
86-
"type": "confirm",
87-
"message": "Set up unit tests"
82+
unit: {
83+
type: 'confirm',
84+
message: 'Set up unit tests'
8885
},
89-
"runner": {
90-
"when": "unit",
91-
"type": "list",
92-
"message": "Pick a test runner",
93-
"choices": [
86+
runner: {
87+
when: 'unit',
88+
type: 'list',
89+
message: 'Pick a test runner',
90+
choices: [
9491
{
95-
"name": "Jest",
96-
"value": "jest",
97-
"short": "jest"
92+
name: 'Jest',
93+
value: 'jest',
94+
short: 'jest'
9895
},
9996
{
100-
"name": "Karma and Mocha",
101-
"value": "karma",
102-
"short": "karma"
97+
name: 'Karma and Mocha',
98+
value: 'karma',
99+
short: 'karma'
103100
},
104101
{
105-
"name": "none (configure it yourself)",
106-
"value": "noTest",
107-
"short": "noTest"
102+
name: 'none (configure it yourself)',
103+
value: 'noTest',
104+
short: 'noTest'
108105
}
109106
]
110107
},
111-
"e2e": {
112-
"type": "confirm",
113-
"message": "Setup e2e tests with Nightwatch?"
108+
e2e: {
109+
type: 'confirm',
110+
message: 'Setup e2e tests with Nightwatch?'
111+
},
112+
autoInstall: {
113+
type: 'list',
114+
message: 'Should we run `npm install` for you after the project has been created? (recommended)',
115+
choices: [
116+
{
117+
name: 'Yes, use NPM',
118+
value: 'npm',
119+
short: 'npm'
120+
},
121+
{
122+
name: 'Yes, use Yarn',
123+
value: 'yarn',
124+
short: 'yarn'
125+
},
126+
{
127+
name: 'No, I will handle that myself',
128+
value: false,
129+
short: 'no'
130+
}
131+
]
114132
}
115133
},
116-
"filters": {
117-
".eslintrc.js": "lint",
118-
".eslintignore": "lint",
119-
"config/test.env.js": "unit || e2e",
120-
"build/webpack.test.conf.js": "e2e || (unit && runner === 'karma')",
121-
"test/unit/**/*": "unit",
122-
"test/unit/index.js": "unit && runner === 'karma'",
123-
"test/unit/jest.conf.js": "unit && runner === 'jest'",
124-
"test/unit/karma.conf.js": "unit && runner === 'karma'",
125-
"test/unit/specs/index.js": "unit && runner === 'karma'",
126-
"test/unit/setup.js": "unit && runner === 'jest'",
127-
"test/e2e/**/*": "e2e",
128-
"src/router/**/*": "router"
134+
filters: {
135+
'.eslintrc.js': 'lint',
136+
'.eslintignore': 'lint',
137+
'config/test.env.js': 'unit || e2e',
138+
'build/webpack.test.conf.js': "unit && runner === 'karma'",
139+
'test/unit/**/*': 'unit',
140+
'test/unit/index.js': "unit && runner === 'karma'",
141+
'test/unit/jest.conf.js': "unit && runner === 'jest'",
142+
'test/unit/karma.conf.js': "unit && runner === 'karma'",
143+
'test/unit/specs/index.js': "unit && runner === 'karma'",
144+
'test/unit/setup.js': "unit && runner === 'jest'",
145+
'test/e2e/**/*': 'e2e',
146+
'src/router/**/*': 'router'
129147
},
130-
"complete": function (data) {
131-
const packageJsonFile = path.join(
132-
data.inPlace ? "" : data.destDirName,
133-
"package.json"
134-
);
135-
const packageJson = JSON.parse(fs.readFileSync(packageJsonFile));
136-
packageJson.devDependencies = sortObject(packageJson.devDependencies);
137-
packageJson.dependencies = sortObject(packageJson.dependencies);
138-
fs.writeFileSync(
139-
packageJsonFile,
140-
JSON.stringify(packageJson, null, 2) + "\n"
141-
);
148+
'complete': function (data, { chalk }) {
149+
150+
const green = chalk.green
142151

143-
const message = `To get started:\n\n ${data.inPlace ? '' : `cd ${data.destDirName}\n `}npm install\n npm run dev\n\nDocumentation can be found at https://vuejs-templates.github.io/webpack`;
144-
console.log("\n" + message.split(/\r?\n/g).map(line => " " + line).join("\n"));
152+
sortDependencies(data, green)
153+
154+
const cwd = path.join(process.cwd(), data.inPlace ? '' : data.destDirName)
155+
156+
if (data.autoInstall) {
157+
installDependencies(cwd, data.autoInstall, green)
158+
.then(() => {
159+
return runLintFix(cwd, data, green)
160+
})
161+
.then(() => {
162+
printMessage(data, green)
163+
})
164+
} else {
165+
printMessage(data, chalk)
166+
}
167+
145168
}
146169
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cli-template-webpack",
3-
"version": "1.2.5",
3+
"version": "1.2.6",
44
"license": "MIT",
55
"description": "A full-featured Webpack setup with hot-reload, lint-on-save, unit testing & css extraction.",
66
"scripts": {

template/.babelrc

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
{
22
"presets": [
33
["env", {
4-
"modules": false
4+
"modules": false,
5+
"targets": {
6+
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7+
}
58
}],
69
"stage-2"
710
],
8-
"plugins": ["transform-runtime"]{{#if_or unit e2e}},
11+
"plugins": ["transform-vue-jsx", "transform-runtime"]{{#if_or unit e2e}},
912
"env": {
1013
"test": {
1114
"presets": ["env", "stage-2"]{{#if_eq runner "karma"}},
12-
"plugins": ["istanbul"]{{/if_eq}}{{#if_eq runner "jest"}},
13-
"plugins": ["transform-es2015-modules-commonjs", "dynamic-import-node"]{{/if_eq}}
15+
"plugins": ["transform-vue-jsx", "istanbul"]{{/if_eq}}{{#if_eq runner "jest"}},
16+
"plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]{{/if_eq}}
1417
}
1518
}{{/if_or}}
1619
}

template/.eslintrc.js

+10
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ module.exports = {
4242
js: 'never',
4343
vue: 'never'
4444
}],
45+
// disallow reassignment of function parameters
46+
// disallow parameter object manipulation except for specific exclusions
47+
'no-param-reassign': ['error', {
48+
props: true,
49+
ignorePropertyModificationsFor: [
50+
'state', // for vuex state
51+
'acc', // for reduce accumulators
52+
'e' // for e.returnvalue
53+
]
54+
}],
4555
// allow optionalDependencies
4656
'import/no-extraneous-dependencies': ['error', {
4757
optionalDependencies: ['test/unit/index.js']

template/build/webpack.prod.conf.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ const webpackConfig = merge(baseWebpackConfig, {
4646
// extract css into its own file
4747
new ExtractTextPlugin({
4848
filename: utils.assetsPath('css/[name].[contenthash].css'),
49-
// set the following option to `true` if you want to extract CSS from
50-
// codesplit chunks into this main css file as well.
51-
// This will result in *all* of your app's CSS being loaded upfront.
52-
allChunks: false,
49+
// Setting the following option to `false` will not extract CSS from codesplit chunks.
50+
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
51+
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
52+
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
53+
allChunks: true,
5354
}),
5455
// Compress extracted CSS. We are using this plugin so that possible
5556
// duplicated CSS from different components can be deduped.

template/config/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict'
2-
// Template version: 1.2.5
2+
// Template version: 1.2.6
33
// see http://vuejs-templates.github.io/webpack for documentation.
44

55
const path = require('path')

template/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@
8484
{{/e2e}}
8585
"autoprefixer": "^7.1.2",
8686
"babel-core": "^6.22.1",
87+
"babel-helper-vue-jsx-merge-props": "^2.0.3",
8788
"babel-loader": "^7.1.1",
89+
"babel-plugin-syntax-jsx": "^6.18.0",
8890
"babel-plugin-transform-runtime": "^6.22.0",
91+
"babel-plugin-transform-vue-jsx": "^3.5.0",
8992
"babel-preset-env": "^1.3.2",
9093
"babel-preset-stage-2": "^6.22.0",
9194
"chalk": "^2.0.1",

0 commit comments

Comments
 (0)