]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test(e2e): add starting page
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 16 Oct 2019 19:37:36 +0000 (21:37 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 16 Oct 2019 19:37:36 +0000 (21:37 +0200)
.gitignore
examples/index.html [new file with mode: 0644]
examples/index.ts [new file with mode: 0644]
examples/tsconfig.json
examples/webpack.config.js
package.json
yarn.lock

index 912122865f864532387ce61382c56ba0216bd252..1198041cd5bcdfde8767ca219751d110912fdc61 100644 (file)
@@ -9,3 +9,4 @@ local.log
 .DS_Store
 e2e/reports
 e2e/screenshots
+examples/__build__
diff --git a/examples/index.html b/examples/index.html
new file mode 100644 (file)
index 0000000..57296fd
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
+    <title>Vue Router Examples</title>
+  </head>
+  <body>
+    <div id="app">
+      <h1>Vue Router Examples</h1>
+
+      <ul>
+        <li v-for="example in examples">
+          <a :href="example">/{{ example }}</a>
+        </li>
+      </ul>
+    </div>
+
+    <script src="index.ts"></script>
+  </body>
+</html>
diff --git a/examples/index.ts b/examples/index.ts
new file mode 100644 (file)
index 0000000..c63a4d3
--- /dev/null
@@ -0,0 +1,17 @@
+import Vue from 'vue'
+
+const context = require.context('.', true, /^.{2,}\/index\.ts$/)
+const DIR_RE = /^\.\/([^/]+)\//
+
+const examples: string[] = []
+context.keys().forEach(path => {
+  const match = DIR_RE.exec(path)
+  if (match) examples.push(match[1])
+  return name
+})
+examples.sort()
+
+new Vue({
+  el: '#app',
+  data: { examples },
+})
index 6cbbe090c65f866a71e695a7c77e0a0560037841..dbdce62e2927e02860a89f7c9ef2685abdda248b 100644 (file)
@@ -1,5 +1,5 @@
 {
-  "include": ["*/*ts"],
+  "include": ["index.ts", "*/*ts"],
   "compilerOptions": {
     "target": "es5",
     "module": "commonjs",
index a8820926d6d3a534460fdcfce0cf28c2e31e80b8..10d4b79423b62fbe459bcb2e11f8cd610b253a6f 100644 (file)
@@ -23,39 +23,24 @@ module.exports = {
 
   mode: process.env.NODE_ENV || 'development',
 
-  // devtool: 'inline-source-map',
+  devtool: 'inline-source-map',
   devServer: {
-    // contentBase: outputPath,
     historyApiFallback: {
       rewrites: examples.map(name => ({
         from: new RegExp(`^/${name}(?:\\/?|/.*)$`),
         to: `/${name}.html`,
       })),
-      // rewrites: [
-      //   { from: /^\/encoding(?:\/?|\/.*)$/, to: '/encoding.html' },
-      //   { from: /^\/hash(?:\/?|\/.*)$/, to: '/hash.html' },
-      // ],
     },
-    // hot: true,
+    hot: true,
   },
 
-  entry: examples.reduce((entries, name) => {
-    entries[name] = resolve(__dirname, name, 'index.ts')
-    return entries
-  }, {}),
-  // entry: {
-  //   encoding: resolve(__dirname, 'encoding/index.ts'),
-  //   hash: resolve(__dirname, 'hash/index.ts'),
-  // },
-  // entry: fs.readdirSync(__dirname).reduce((entries, dir) => {
-  //   const fullDir = path.join(__dirname, dir)
-  //   const entry = path.join(fullDir, 'index.ts')
-  //   if (fs.statSync(fullDir).isDirectory() && fs.existsSync(entry)) {
-  //     entries[dir] = ['es6-promise/auto', entry]
-  //   }
-
-  //   return entries
-  // }, {}),
+  entry: examples.reduce(
+    (entries, name) => {
+      entries[name] = resolve(__dirname, name, 'index.ts')
+      return entries
+    },
+    { index: resolve(__dirname, 'index.ts') }
+  ),
 
   output: {
     path: join(__dirname, '__build__'),
@@ -89,6 +74,11 @@ module.exports = {
           template: resolve(__dirname, name, 'index.html'),
         })
     ),
+    new HtmlWebpackPlugin({
+      filename: 'index.html',
+      chunks: ['index'],
+      template: resolve(__dirname, 'index.html'),
+    }),
     new webpack.DefinePlugin({
       'process.env': {
         NODE_ENV: JSON.stringify(process.env.NODE_ENV),
index 87967edbf8b8cf8b99b986f935dd7ead5a9d9bb5..7e639cf759e746c0d617ce1aa7a179949cfcf0b0 100644 (file)
@@ -19,6 +19,8 @@
   "devDependencies": {
     "@types/jest": "^24.0.18",
     "@types/jsdom": "^12.2.4",
+    "@types/webpack": "^4.39.3",
+    "@types/webpack-env": "^1.14.1",
     "@vue/test-utils": "^1.0.0-beta.29",
     "axios": "^0.19.0",
     "browserstack-local": "^1.4.2",
index 6caaf0d6a0e7542304e5d06752e5fd2d98a679d9..720869a131c1af2507881f436ffed1a92a780b04 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
     "@types/istanbul-reports" "^1.1.1"
     "@types/yargs" "^13.0.0"
 
+"@types/anymatch@*":
+  version "1.3.1"
+  resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a"
+  integrity sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==
+
 "@types/babel__core@^7.1.0":
   version "7.1.3"
   resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.3.tgz#e441ea7df63cd080dfcd02ab199e6d16a735fc30"
   dependencies:
     "@types/node" "*"
 
+"@types/source-list-map@*":
+  version "0.1.2"
+  resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9"
+  integrity sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==
+
 "@types/stack-utils@^1.0.1":
   version "1.0.1"
   resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
   integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw==
 
+"@types/tapable@*":
+  version "1.0.4"
+  resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370"
+  integrity sha512-78AdXtlhpCHT0K3EytMpn4JNxaf5tbqbLcbIRoQIHzpTIyjpxLQKRoxU55ujBXAtg3Nl2h/XWvfDa9dsMOd0pQ==
+
 "@types/tough-cookie@*":
   version "2.3.5"
   resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-2.3.5.tgz#9da44ed75571999b65c37b60c9b2b88db54c585d"
   integrity sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg==
 
+"@types/uglify-js@*":
+  version "3.0.4"
+  resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.4.tgz#96beae23df6f561862a830b4288a49e86baac082"
+  integrity sha512-SudIN9TRJ+v8g5pTG8RRCqfqTMNqgWCKKd3vtynhGzkIIjxaicNAMuY5TRadJ6tzDu3Dotf3ngaMILtmOdmWEQ==
+  dependencies:
+    source-map "^0.6.1"
+
+"@types/webpack-env@^1.14.1":
+  version "1.14.1"
+  resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.14.1.tgz#0d8a53f308f017c53a5ddc3d07f4d6fa76b790d7"
+  integrity sha512-0Ki9jAAhKDSuLDXOIMADg54Hu60SuBTEsWaJGGy5cV+SSUQ63J2a+RrYYGrErzz39fXzTibhKrAQJAb8M7PNcA==
+
+"@types/webpack-sources@*":
+  version "0.1.5"
+  resolved "https://registry.yarnpkg.com/@types/webpack-sources/-/webpack-sources-0.1.5.tgz#be47c10f783d3d6efe1471ff7f042611bd464a92"
+  integrity sha512-zfvjpp7jiafSmrzJ2/i3LqOyTYTuJ7u1KOXlKgDlvsj9Rr0x7ZiYu5lZbXwobL7lmsRNtPXlBfmaUD8eU2Hu8w==
+  dependencies:
+    "@types/node" "*"
+    "@types/source-list-map" "*"
+    source-map "^0.6.1"
+
+"@types/webpack@^4.39.3":
+  version "4.39.3"
+  resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.39.3.tgz#1d55f8fce117a325368bf7612950552ee4ed4467"
+  integrity sha512-afGNNuTfKk1YfHrQ+IwF0QhDkSSMIMMt8BRRErTKaGVvWTMABDjT22/4kJ4bRoSzir9LVgxuuceyZ4Z5I82Cyg==
+  dependencies:
+    "@types/anymatch" "*"
+    "@types/node" "*"
+    "@types/tapable" "*"
+    "@types/uglify-js" "*"
+    "@types/webpack-sources" "*"
+    source-map "^0.6.0"
+
 "@types/yargs-parser@*":
   version "13.1.0"
   resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-13.1.0.tgz#c563aa192f39350a1d18da36c5a8da382bbd8228"