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

Commit 353e70c

Browse files
authored
Merge pull request #2 from ryutamaki/feature/webpack2
webpack v2
2 parents 876dbb4 + 4c3fe47 commit 353e70c

26 files changed

+255
-187
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ $ npm run dev
3434
- HTML minified with [html-minifier](https://github.com/kangax/html-minifier).
3535
- CSS across all components extracted into a single file and minified with [cssnano](https://github.com/ben-eb/cssnano).
3636
- 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.
37+
- Use `npm run build --report`to build with bundle size analytics.
3738

3839
- `npm run unit`: Unit tests run in PhantomJS with [Karma](http://karma-runner.github.io/0.13/index.html) + [Mocha](http://mochajs.org/) + [karma-webpack](https://github.com/webpack/karma-webpack).
3940
- Supports typescript in test files.

circle.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
machine:
2+
node:
3+
version: 6
4+
5+
test:
6+
override:
7+
- bash test.sh

docs/proxy.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,18 @@ module.exports = {
2424
```
2525

2626
The above example will proxy the request `/api/posts/1` to `http://jsonplaceholder.typicode.com/posts/1`.
27+
28+
## URL Matching
29+
30+
In addition to static urls you can also use glob patterns to match URLs, e.g. `/api/**`. See [Context Matching](https://github.com/chimurai/http-proxy-middleware#context-matching) for more details. In addition, you can provide a `filter` option that can be a custom function to determine whether a request should be proxied:
31+
32+
``` js
33+
proxyTable: {
34+
'*': {
35+
target: 'http://jsonplaceholder.typicode.com',
36+
filter: function (pathname, req) {
37+
return pathname.match('^/api') && req.method === 'GET'
38+
}
39+
}
40+
}
41+
```

docs/structure.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
│ │   ├── index.js # test build entry file
2222
│ │   └── karma.conf.js # test runner config file
2323
│ └── e2e/ # e2e tests
24-
│    ├── specs/ # test spec files
25-
│    ├── custom-assertions/ # custom assertions for e2e tests
26-
│    ├── runner.js # test runner script
27-
   └── nightwatch.conf.js # test runner config file
28-
├── .editorconfig.js # editor config
24+
   ├── specs/ # test spec files
25+
   ├── custom-assertions/ # custom assertions for e2e tests
26+
   ├── runner.js # test runner script
27+
    └── nightwatch.conf.js # test runner config file
28+
├── .editorconfig # editor config
2929
├── index.html # index.html template
3030
└── package.json # build scripts and dependencies
3131
```

meta.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ module.exports = {
4040
}
4141
]
4242
},
43+
"router": {
44+
"type": "confirm",
45+
"message": "Install vue-router?"
46+
},
4347
"unit": {
4448
"type": "confirm",
4549
"message": "Setup unit tests with Karma + Mocha?"
@@ -52,7 +56,9 @@ module.exports = {
5256
"filters": {
5357
"config/test.env.js": "unit || e2e",
5458
"test/unit/**/*": "unit",
55-
"test/e2e/**/*": "e2e"
59+
"build/webpack.test.conf.js": "unit",
60+
"test/e2e/**/*": "e2e",
61+
"src/router/**/*": "router"
5662
},
5763
"completeMessage": "To get started:\n\n cd {{destDirName}}\n npm install\n npm run dev\n\nDocumentation can be found at https://vuejs-templates.github.io/webpack"
5864
};

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"description": "A full-featured Webpack setup with hot-reload, unit testing & css extraction.",
66
"scripts": {
77
"docs": "cd docs && gitbook serve",
8-
"deploy-docs": "bash ./deploy-docs.sh"
8+
"docs:deploy": "bash ./deploy-docs.sh"
9+
},
10+
"devDependencies": {
11+
"vue-cli": "^2.8.1"
912
}
1013
}

template/.babelrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
2-
"presets": ["es2015", "stage-2"],
2+
"presets": [
3+
["es2015", { "modules": false }],
4+
"stage-2"
5+
],
36
"plugins": ["transform-runtime"],
47
"comments": false,
58
"env": {

template/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ npm run dev
1313

1414
# build for production with minification
1515
npm run build
16+
17+
# build for production and view the bundle analyzer report
18+
npm run build --report
1619
{{#unit}}
1720

1821
# run unit tests

template/build/build.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
// https://github.com/shelljs/shelljs
22
require('./check-versions')()
3-
require('shelljs/global')
4-
env.NODE_ENV = 'production'
53

6-
var path = require('path')
7-
var config = require('../config')
4+
process.env.NODE_ENV = 'production'
5+
86
var ora = require('ora')
7+
var path = require('path')
8+
var chalk = require('chalk')
9+
var shell = require('shelljs')
910
var webpack = require('webpack')
11+
var config = require('../config')
1012
var webpackConfig = require('./webpack.prod.conf')
1113

12-
console.log(
13-
' Tip:\n' +
14-
' Built files are meant to be served over an HTTP server.\n' +
15-
' Opening index.html over file:// won\'t work.\n'
16-
)
17-
1814
var spinner = ora('building for production...')
1915
spinner.start()
2016

2117
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
22-
rm('-rf', assetsPath)
23-
mkdir('-p', assetsPath)
24-
cp('-R', 'static/*', assetsPath)
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
2523

2624
webpack(webpackConfig, function (err, stats) {
2725
spinner.stop()
@@ -32,5 +30,11 @@ webpack(webpackConfig, function (err, stats) {
3230
children: false,
3331
chunks: false,
3432
chunkModules: false
35-
}) + '\n')
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+
))
3640
})

template/build/check-versions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var semver = require('semver')
21
var chalk = require('chalk')
2+
var semver = require('semver')
33
var packageConfig = require('../package.json')
4-
var exec = function (cmd) {
5-
return require('child_process')
6-
.execSync(cmd).toString().trim()
4+
5+
function exec (cmd) {
6+
return require('child_process').execSync(cmd).toString().trim()
77
}
88

99
var versionRequirements = [

0 commit comments

Comments
 (0)