You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ge...@apache.org on 2020/03/27 17:31:08 UTC
[incubator-annotator] 01/01: Reorganise webpack-related files
This is an automated email from the ASF dual-hosted git repository.
gerben pushed a commit to branch reorg-webpack
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit b04cea0e84c0f685e60113e5880e90e345bc78c0
Author: Gerben <ge...@treora.com>
AuthorDate: Fri Mar 27 17:19:24 2020 +0100
Reorganise webpack-related files
- group all web(pack)-related files under /web
- add web:build and web:server scripts (yarn start = yarn run web:server)
- name build outputs 'bundle.js', make git ignore those
- make pages also work when opened without server (as file://…)
---
.gitignore | 1 +
package.json | 6 ++++--
{demo => web/demo}/index.html | 3 ++-
{demo => web/demo}/index.js | 0
index.html => web/index.html | 5 +++--
{test => web/test}/index.html | 3 ++-
webpack.config.js => web/webpack.config.js | 7 +++++--
7 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
index 3672b5c..ded4f3b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
.nyc_output
coverage
node_modules
+web/**/bundle.js
/packages/*/LICENSE
/packages/*/NOTICE
/packages/*/esm
diff --git a/package.json b/package.json
index c6e857b..574e0e0 100644
--- a/package.json
+++ b/package.json
@@ -24,9 +24,11 @@
"lint": "eslint --fix --quiet .",
"prepare": "lerna run prepare",
"prepublishOnly": "yarn run build",
- "start": "webpack-dev-server --hot --mode development",
+ "start": "yarn run web:server",
"test": "cross-env BABEL_ENV=test nyc mocha packages/*/test/**/*.js",
- "validate": "cross-env BABEL_ENV=test mocha test/**/*.js"
+ "validate": "cross-env BABEL_ENV=test mocha test/**/*.js",
+ "web:build": "webpack --config=web/webpack.config.js --mode development",
+ "web:server": "webpack-dev-server --config=web/webpack.config.js --hot --mode development"
},
"husky": {
"hooks": {
diff --git a/demo/index.html b/web/demo/index.html
similarity index 98%
rename from demo/index.html
rename to web/demo/index.html
index facccec..cc9230c 100644
--- a/demo/index.html
+++ b/web/demo/index.html
@@ -79,4 +79,5 @@ under the License.
<p>Here is the selector in JSON format:
<pre><code id="parsed"></code></pre>
</main>
- <script src="/demo.js"></script>
+ <script src="bundle.js"></script>
+</html>
diff --git a/demo/index.js b/web/demo/index.js
similarity index 100%
rename from demo/index.js
rename to web/demo/index.js
diff --git a/index.html b/web/index.html
similarity index 89%
rename from index.html
rename to web/index.html
index 67157d5..fe79268 100644
--- a/index.html
+++ b/web/index.html
@@ -27,7 +27,8 @@ under the License.
<h1>Welcome to Apache Annotator (incubating)</h1>
<h2>Getting Started</h2>
<ul>
- <li>Visit the <a href="/demo/">demonstration page</a>.
- <li>Run the <a href="/test/">test suite</a>.
+ <li>Visit the <a href="demo/index.html">demonstration page</a>.
+ <li>Run the <a href="test/index.html">test suite</a>.
</ul>
</main>
+</html>
diff --git a/test/index.html b/web/test/index.html
similarity index 95%
rename from test/index.html
rename to web/test/index.html
index d40890c..4f157cc 100644
--- a/test/index.html
+++ b/web/test/index.html
@@ -20,4 +20,5 @@ under the License.
<html>
<meta charset="utf-8">
<title>Apache Annotator (incubating) test suite</title>
- <script src="/test.js"></script>
+ <script src="bundle.js"></script>
+</html>
diff --git a/webpack.config.js b/web/webpack.config.js
similarity index 91%
rename from webpack.config.js
rename to web/webpack.config.js
index b20514a..26dee47 100644
--- a/webpack.config.js
+++ b/web/webpack.config.js
@@ -25,6 +25,9 @@ const path = require('path');
module.exports = {
context: path.resolve(__dirname),
+ devServer: {
+ contentBase: path.resolve(__dirname),
+ },
entry: {
demo: './demo/index.js',
test: [
@@ -43,7 +46,7 @@ module.exports = {
],
},
output: {
- filename: '[name].js',
- publicPath: '/',
+ path: path.resolve(__dirname),
+ filename: '[name]/bundle.js',
},
};