Alexey Velikiy 5 سال پیش
والد
کامیت
d3c564d783
5فایلهای تغییر یافته به همراه27 افزوده شده و 8 حذف شده
  1. 5 2
      README.md
  2. 7 1
      app.js
  3. 9 0
      build/webpack.dev.conf.js
  4. 5 5
      package.json
  5. 1 0
      test_module.js

+ 5 - 2
README.md

@@ -1,2 +1,5 @@
-# express-webpack-example
-Repo showing how to bundle an express.js application to a bundle with webpack
+# Express Webpack example
+Repo showing how to bundle an [Express.js](https://github.com/expressjs/express) 
+application to a bundle with [Webpack](https://github.com/webpack/webpack).
+
+Project has production and development build.

+ 7 - 1
app.js

@@ -1,8 +1,14 @@
+import { MODULE_CONST } from './test_module'
+
 var express = require('express');
 var app = express();
 
-app.get('/', function(req, res){
+app.get('/', function(req, res) {
    res.send("Hello world!");
 });
 
+app.get('/test-module', function(req, res) {
+  res.send(MODULE_CONST);
+});
+
 app.listen(3000);

+ 9 - 0
build/webpack.dev.conf.js

@@ -1,5 +1,14 @@
 const base = require('./webpack.base.conf');
 
 base.mode = 'development';
+base.externals = [
+  function(context, request, callback) {
+    if(request[0] == '.') {
+      callback();
+    } else {
+      callback(null, "require('" + request + "')");
+    }
+  }
+],
 
 module.exports = base;

+ 5 - 5
package.json

@@ -4,10 +4,9 @@
   "description": "Repo showing how to bundle an express.js application to a bundle with webpack",
   "main": "app.js",
   "scripts": {
-    "start": "node dist/server.js",
+    "start": "node dist/app.js",
     "build": "webpack --config build/webpack.prod.conf.js",
-    "dev": "webpack --config build/webpack.dev.conf.js",
-    "test": "echo \"Error: no test specified\" && exit 1"
+    "dev": "webpack --config build/webpack.dev.conf.js"
   },
   "repository": {
     "type": "git",
@@ -16,8 +15,9 @@
   "keywords": [
     "node.js",
     "webpack",
-    "express.js",
-    "javascript"
+    "expressjs",
+    "javascript",
+    "cicd"
   ],
   "author": "CorpGlory Inc.",
   "license": "MIT",

+ 1 - 0
test_module.js

@@ -0,0 +1 @@
+export const MODULE_CONST = "Hello from the test module";