Skip to content

Commit c4943a1

Browse files
committed
Merge branch 'develop'
* develop: bump version 1.2.5 some small updates to the docs Adds support for the video poster attribute (#1123) babel-register use only for e2e tests (#1120) Update project creation: sort dependencies in package.json (#1118) Fix bug from PR #1082 FIX: convert env variable PORT to a number. Minor refactoring of build scripts (#1082) ESLint config clean up (#1093) Switch to uglifyjs-webpack-plugin (#1119) change bad spaces into normal spaces and removing trailing space (#1132) prevent empty line when unit = y & e2e = n Update meta.js (#1091) docs(README): Update usage to init from develop branch (#1092) Use actual host for notification (#1101). (#1103) prevent webpack from injecting useless mocks
2 parents 3c15450 + 4133502 commit c4943a1

18 files changed

+186
-90
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ $ npm install
2121
$ npm run dev
2222
```
2323

24+
This will scaffold the project using the `master` branch. If you wish to use the latest version of the webpack template, do the following instead:
25+
26+
``` bash
27+
$ vue init webpack#develop my-project
28+
```
29+
30+
:warning: **The develop branch is not considered stable and can contain bugs or not build at all, so use at your own risk.**
31+
2432
The development server will run on port 8080 by default. If that port is already in use on your machine, the next free port will be used.
2533

2634
## What's Included
@@ -33,7 +41,7 @@ The development server will run on port 8080 by default. If that port is already
3341
- Source maps
3442

3543
- `npm run build`: Production ready build.
36-
- JavaScript minified with [UglifyJS](https://github.com/mishoo/UglifyJS2).
44+
- JavaScript minified with [UglifyJS v3](https://github.com/mishoo/UglifyJS2/tree/harmony).
3745
- HTML minified with [html-minifier](https://github.com/kangax/html-minifier).
3846
- CSS across all components extracted into a single file and minified with [cssnano](https://github.com/ben-eb/cssnano).
3947
- Static assets compiled with version hashes for efficient long-term caching, and an auto-generated production `index.html` with proper URLs to these generated assets.

docs/backend.md

+21-7
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,31 @@ Let's take a look at the default `config/index.js`:
1010
const path = require('path')
1111

1212
module.exports = {
13+
dev: {
14+
/ Paths
15+
assetsSubDirectory: 'static',
16+
assetsPublicPath: '/',
17+
proxyTable: {},
18+
19+
// Various Dev Server settings
20+
host: 'localhost',
21+
port: 8080,
22+
23+
// skipping other options as they are only convenience features
24+
},
1325
build: {
14-
index: path.resolve(__dirname, 'dist/index.html'),
15-
assetsRoot: path.resolve(__dirname, 'dist'),
26+
// Template for index.html
27+
index: path.resolve(__dirname, '../dist/index.html'),
28+
29+
// Paths
30+
assetsRoot: path.resolve(__dirname, '../dist'),
1631
assetsSubDirectory: 'static',
1732
assetsPublicPath: '/',
18-
productionSourceMap: true
33+
34+
productionSourceMap: true,
35+
36+
// skipping the rest ...
1937
},
20-
dev: {
21-
port: 8080,
22-
proxyTable: {}
23-
}
2438
}
2539
```
2640

docs/commands.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ All build commands are executed via [NPM Scripts](https://docs.npmjs.com/misc/sc
1616

1717
> Build assets for production. See [Integrating with Backend Framework](backend.md) for more details.
1818
19-
- JavaScript minified with [UglifyJS](https://github.com/mishoo/UglifyJS2).
19+
- JavaScript minified with [UglifyJS v3](https://github.com/mishoo/UglifyJS2/tree/harmony).
2020
- HTML minified with [html-minifier](https://github.com/kangax/html-minifier).
2121
- CSS across all components extracted into a single file and minified with [cssnano](https://github.com/ben-eb/cssnano).
2222
- All static assets compiled with version hashes for efficient long-term caching, and a production `index.html` is auto-generated with proper URLs to these generated assets.
@@ -36,3 +36,7 @@ All build commands are executed via [NPM Scripts](https://docs.npmjs.com/misc/sc
3636
- Works with one command out of the box:
3737
- Selenium and chromedriver dependencies automatically handled.
3838
- Automatically spawns the Selenium server.
39+
40+
### `npm run lint`
41+
42+
> Runs eslint and reports any linting errors in your code. See [Linter Configuration](linter.md)

docs/linter.md

+11
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@ If you are not happy with the default linting rules, you have several options:
1414
2. Pick a different ESLint preset when generating the project, for example [eslint-config-airbnb](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb).
1515

1616
3. Pick "none" for ESLint preset when generating the project and define your own rules. See [ESLint documentation](https://eslint.org/docs/rules/) for more details.
17+
18+
## Fixing Linting Errors
19+
20+
You can run the following command to let eslint fix any errors it finds (if it can - not all errors are fixable like this):
21+
22+
```
23+
npm run lint -- --fix
24+
```
25+
26+
*(The `--` in the middle is necessary to ensure the `--fix` option is passdd to `eslint`, not to `npm`)*
27+

docs/pre-processors.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ Once installed, you can use the pre-processors inside your `*.vue` components us
2525

2626
### PostCSS
2727

28-
Styles in `*.vue` files are piped through PostCSS by default, so you don't need to use a specific loader for it. You can simply add PostCSS plugins you want to use in `build/webpack.base.conf.js` under the `vue` block:
28+
Styles in `*.vue` files and style files (`*.css`, `*.scss` etc) are piped through PostCSS by default, so you don't need to use a specific loader for it.
29+
30+
You can simply add PostCSS plugins you want to use to the `.postcssrc.js`file in your project's root directory:
2931

3032
``` js
31-
// build/webpack.base.conf.js
33+
// https://github.com/michael-ciniawsky/postcss-load-config
34+
3235
module.exports = {
33-
// ...
34-
vue: {
35-
postcss: [/* your plugins */]
36+
"plugins": {
37+
// to edit target browsers: use "browserslist" field in package.json
38+
"postcss-import": {},
39+
"autoprefixer": {}
3640
}
3741
}
3842
```

docs/structure.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,25 @@
1818
├── test/
1919
│ └── unit/ # unit tests
2020
│ │ ├── specs/ # test spec files
21-
│ │ ├── setup.js # file that runs before Jest tests
21+
│ │ ├── eslintrc # config file for eslint with extra settings only for unit tests
2222
│ │ ├── index.js # test build entry file
23-
│ │ └── karma.conf.js # test runner config file
23+
│ │ ├── jest.conf.js # Config file when using Jest for unit tests
24+
│ │ └── karma.conf.js # test runner config file when using Karma for unit tests
25+
│ │ ├── setup.js # file that runs before Jest runs your unit tests
2426
│ └── e2e/ # e2e tests
2527
│ │   ├── specs/ # test spec files
2628
│ │   ├── custom-assertions/ # custom assertions for e2e tests
2729
│ │   ├── runner.js # test runner script
2830
│ │   └── nightwatch.conf.js # test runner config file
2931
├── .babelrc # babel config
30-
├── .postcssrc.js # postcss config
32+
├── .editorconfig # indentation, spaces/tabs and similar settings for your editor
3133
├── .eslintrc.js # eslint config
32-
├── .editorconfig # editor config
34+
├── .eslintignore.js # eslint ignore rules
35+
├── .gitignore # sensible defaults for gitignore
36+
├── .postcssrc.js # postcss config
3337
├── index.html # index.html template
34-
└── package.json # build scripts and dependencies
38+
├── package.json # build scripts and dependencies
39+
└── README.md # Default README file
3540
```
3641

3742
### `build/`

meta.js

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
const path = require('path');
2+
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+
}
12+
113
module.exports = {
214
"helpers": {
315
"if_or": function (v1, v2, options) {
@@ -72,7 +84,7 @@ module.exports = {
7284
},
7385
"unit": {
7486
"type": "confirm",
75-
"message": "Setup unit tests"
87+
"message": "Set up unit tests"
7688
},
7789
"runner": {
7890
"when": "unit",
@@ -115,5 +127,20 @@ module.exports = {
115127
"test/e2e/**/*": "e2e",
116128
"src/router/**/*": "router"
117129
},
118-
"completeMessage": "To get started:\n\n {{^inPlace}}cd {{destDirName}}\n {{/inPlace}}npm install\n npm run dev\n\nDocumentation can be found at https://vuejs-templates.github.io/webpack"
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+
);
142+
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"));
145+
}
119146
};

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.4",
3+
"version": "1.2.5",
44
"license": "MIT",
55
"description": "A full-featured Webpack setup with hot-reload, lint-on-save, unit testing & css extraction.",
66
"scripts": {

template/.eslintrc.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,32 @@ module.exports = {
2222
],
2323
{{#if_eq lintConfig "airbnb"}}
2424
// check if imports actually resolve
25-
'settings': {
25+
settings: {
2626
'import/resolver': {
27-
'webpack': {
28-
'config': 'build/webpack.base.conf.js'
27+
webpack: {
28+
config: 'build/webpack.base.conf.js'
2929
}
3030
}
3131
},
3232
{{/if_eq}}
3333
// add your custom rules here
34-
'rules': {
34+
rules: {
3535
{{#if_eq lintConfig "standard"}}
36-
// allow paren-less arrow functions
37-
'arrow-parens': 0,
3836
// allow async-await
39-
'generator-star-spacing': 0,
37+
'generator-star-spacing': 'off',
4038
{{/if_eq}}
4139
{{#if_eq lintConfig "airbnb"}}
4240
// don't require .vue extension when importing
4341
'import/extensions': ['error', 'always', {
44-
'js': 'never',
45-
'vue': 'never'
42+
js: 'never',
43+
vue: 'never'
4644
}],
4745
// allow optionalDependencies
4846
'import/no-extraneous-dependencies': ['error', {
49-
'optionalDependencies': ['test/unit/index.js']
47+
optionalDependencies: ['test/unit/index.js']
5048
}],
5149
{{/if_eq}}
5250
// allow debugger during development
53-
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
51+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
5452
}
5553
}

template/build/build.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spinner.start()
1616

1717
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
1818
if (err) throw err
19-
webpack(webpackConfig, function (err, stats) {
19+
webpack(webpackConfig, (err, stats) => {
2020
spinner.stop()
2121
if (err) throw err
2222
process.stdout.write(stats.toString({

template/build/check-versions.js

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const chalk = require('chalk')
33
const semver = require('semver')
44
const packageConfig = require('../package.json')
55
const shell = require('shelljs')
6+
67
function exec (cmd) {
78
return require('child_process').execSync(cmd).toString().trim()
89
}
@@ -25,8 +26,10 @@ if (shell.which('npm')) {
2526

2627
module.exports = function () {
2728
const warnings = []
29+
2830
for (let i = 0; i < versionRequirements.length; i++) {
2931
const mod = versionRequirements[i]
32+
3033
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
3134
warnings.push(mod.name + ': ' +
3235
chalk.red(mod.currentVersion) + ' should be ' +
@@ -39,10 +42,12 @@ module.exports = function () {
3942
console.log('')
4043
console.log(chalk.yellow('To use this template, you must update following to modules:'))
4144
console.log()
45+
4246
for (let i = 0; i < warnings.length; i++) {
4347
const warning = warnings[i]
4448
console.log(' ' + warning)
4549
}
50+
4651
console.log()
4752
process.exit(1)
4853
}

template/build/utils.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
const path = require('path')
33
const config = require('../config')
44
const ExtractTextPlugin = require('extract-text-webpack-plugin')
5-
const pkg = require('../package.json')
5+
const packageConfig = require('../package.json')
66

77
exports.assetsPath = function (_path) {
88
const assetsSubDirectory = process.env.NODE_ENV === 'production'
99
? config.build.assetsSubDirectory
1010
: config.dev.assetsSubDirectory
11+
1112
return path.posix.join(assetsSubDirectory, _path)
1213
}
1314

@@ -21,7 +22,7 @@ exports.cssLoaders = function (options) {
2122
}
2223
}
2324

24-
var postcssLoader = {
25+
const postcssLoader = {
2526
loader: 'postcss-loader',
2627
options: {
2728
sourceMap: options.sourceMap
@@ -31,6 +32,7 @@ exports.cssLoaders = function (options) {
3132
// generate loader string to be used with extract text plugin
3233
function generateLoaders (loader, loaderOptions) {
3334
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
35+
3436
if (loader) {
3537
loaders.push({
3638
loader: loader + '-loader',
@@ -68,28 +70,29 @@ exports.cssLoaders = function (options) {
6870
exports.styleLoaders = function (options) {
6971
const output = []
7072
const loaders = exports.cssLoaders(options)
73+
7174
for (const extension in loaders) {
7275
const loader = loaders[extension]
7376
output.push({
7477
test: new RegExp('\\.' + extension + '$'),
7578
use: loader
7679
})
7780
}
81+
7882
return output
7983
}
8084

81-
exports.createNotifierCallback = function () {
85+
exports.createNotifierCallback = () => {
8286
const notifier = require('node-notifier')
8387

8488
return (severity, errors) => {
85-
if (severity !== 'error') {
86-
return
87-
}
88-
const error = errors[0]
89+
if (severity !== 'error') return
8990

91+
const error = errors[0]
9092
const filename = error.file && error.file.split('!').pop()
93+
9194
notifier.notify({
92-
title: pkg.name,
95+
title: packageConfig.name,
9396
message: severity + ': ' + error.name,
9497
subtitle: filename || '',
9598
icon: path.join(__dirname, 'logo.png')

template/build/vue-loader.conf.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ const sourceMapEnabled = isProduction
66
? config.build.productionSourceMap
77
: config.dev.cssSourceMap
88

9-
109
module.exports = {
1110
loaders: utils.cssLoaders({
1211
sourceMap: sourceMapEnabled,
1312
extract: isProduction
1413
}),
1514
cssSourceMap: sourceMapEnabled,
16-
cacheBusting: config.dev.cacheBusting,
15+
cacheBusting: config.dev.cacheBusting,
1716
transformToRequire: {
18-
video: 'src',
17+
video: ['src', 'poster'],
1918
source: 'src',
2019
img: 'src',
2120
image: 'xlink:href'

0 commit comments

Comments
 (0)