Browse Source

使用Gradle打包Vue项目到后台项目

huxz 8 years ago
parent
commit
5e9f2a73c9

+ 1 - 0
.gitignore

@@ -59,6 +59,7 @@ repo/
 dist/
 dist/
 node_modules/
 node_modules/
 !/sso-manage-console-web/build/
 !/sso-manage-console-web/build/
+sso-manage-console/src/main/resources/public/
 
 
 # Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
 # Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
 !/.mvn/wrapper/maven-wrapper.jar
 !/.mvn/wrapper/maven-wrapper.jar

+ 11 - 0
sso-manage-console-web/README.md

@@ -41,4 +41,15 @@ yarn run build
 python -m http.server
 python -m http.server
 ```
 ```
 
 
+## Deploy
+
+Build vue project, and copy outputs to Java Backend
+
+``` bash 
+gradle :sso-manage-console-web:npmRunBuild
+
+# Package spring boot application
+gradle build
+```
+
 For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
 For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).

+ 15 - 2
sso-manage-console-web/build.gradle

@@ -1,2 +1,15 @@
-group 'com.uas.sso'
-version '0.0.1-SNAPSHOT'
+plugins {
+  id "com.moowork.node" version "1.2.0"
+}
+
+node {
+  download = false
+}
+
+task npmRunDev(group: 'node', type: NpmTask) {
+  args = ["run", "dev"]
+}
+
+task npmRunBuild(group: 'node', type: NpmTask) {
+  args = ["run", "build"]
+}

+ 5 - 3
sso-manage-console-web/config/index.js

@@ -4,6 +4,8 @@
 
 
 const path = require('path')
 const path = require('path')
 
 
+const dist = '../../sso-manage-console/src/main/resources/public'
+
 module.exports = {
 module.exports = {
   dev: {
   dev: {
 
 
@@ -51,10 +53,10 @@ module.exports = {
 
 
   build: {
   build: {
     // Template for index.html
     // Template for index.html
-    index: path.resolve(__dirname, '../dist/index.html'),
+    index: path.resolve(__dirname, dist + '/index.html'),
 
 
-    // Paths
-    assetsRoot: path.resolve(__dirname, '../dist'),
+    // Paths, move files to backed server program
+    assetsRoot: path.resolve(__dirname, dist),
     assetsSubDirectory: 'static',
     assetsSubDirectory: 'static',
     assetsPublicPath: '/',
     assetsPublicPath: '/',
 
 

+ 0 - 0
sso-manage-console-web/static/icon_brand.png → sso-manage-console-web/static/images/icon_brand.png