Commit 1781905f authored by 邓晓峰's avatar 邓晓峰

feat: add .gitllab-ci.yml

parent c1344777
variables:
TARGET_REPO_2021: "F:/CIV_CI/CivWebPublish2021_CIVWeb5/CivWebPublish2021/"
TARGET_REPO_2020: "F:/CIV_CI/CivWebPublish2021_CIVWeb5/CivWebPublish2020"
TARGET_REPO_2019: "F:/CIV_CI/CivWebPublish2021_CIVWeb5/CivWebPublish/"
before_script:
- chcp 65001
- 'git config core.autocrlf false'
stages:
- install
- package
- push
install:
stage: install
script:
- npm install
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
only:
refs:
- master
variables:
- $NPM_INSTALL == "true"
when: manual
package:
stage: package
script:
- echo "${CI_PROJECT_DIR}"
- npm run build --releasepath=../CivWebPublish2021
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
only:
- master
when: manual
push_2021:
variables:
GIT_STRATEGY: none
stage: push
script:
- 'cd "${TARGET_REPO_2021}"'
- 'git reset --hard head'
- 'git clean -fd'
- 'git remote set-url origin "https://${GIT_ACCESS_USER}:${GIT_ACCESS_PASSWORD}@g.civnet.cn:8443/CivPublish/CivWebPublish2021.git"'
- 'git pull origin map'
- 'robocopy "${CI_PROJECT_DIR}/../CivWebPublish2021/civmanage" "${TARGET_REPO_2021}/civmanage" /S ;
IF ((${LASTEXITCODE} -le 8)) {cmd /c "exit /b 0"}'
- 'git add . ; git reset HEAD Web.config CityInterface/Web.config CityWebFW/Web.config ; git commit -m "auto package civmanage."'
#- 'git push origin map'
only:
- master
when: manual
push_2020:
variables:
GIT_STRATEGY: none
stage: push
script:
- 'cd "${TARGET_REPO_2020}"'
- 'git reset --hard head'
- 'git clean -fd'
- 'git remote set-url origin "https://${GIT_ACCESS_USER}:${GIT_ACCESS_PASSWORD}@g.civnet.cn:8443/CivPublish/CivWebPublish2020.git"'
- 'git pull origin map'
- 'robocopy "${CI_PROJECT_DIR}/../CivWebPublish2021/civmanage" "${TARGET_REPO_2020}/civmanage" /S ;
IF ((${LASTEXITCODE} -le 8)) {cmd /c "exit /b 0"}'
- 'git add . ; git reset HEAD Web.config CityInterface/Web.config CityWebFW/Web.config ; git commit -m "auto package civmanage."'
#- 'git push origin map'
only:
- master
when: manual
push_2019:
variables:
GIT_STRATEGY: none
stage: push
script:
- 'cd "${TARGET_REPO_2019}"'
- 'git reset --hard head'
- 'git clean -fd'
- 'git remote set-url origin "https://${GIT_ACCESS_USER}:${GIT_ACCESS_PASSWORD}@g.civnet.cn:8443/CivPublish/CivWebPublish.git"'
- 'git pull origin map'
- 'robocopy "${CI_PROJECT_DIR}/../CivWebPublish2021/civmanage" "${TARGET_REPO_2019}/civmanage" /S ;
IF ((${LASTEXITCODE} -le 8)) {cmd /c "exit /b 0"}'
- 'git add . ; git reset HEAD Web.config CityInterface/Web.config CityWebFW/Web.config ; git commit -m "auto package civmanage."'
#- 'git push origin map'
only:
- master
when: manual
const rm = require('rimraf'); const rm = require('rimraf');
const path = require('path'); const path = require('path');
rm(process.env.npm_config_releasepath ? path.resolve(process.env.npm_config_releasepath, 'CivManage'): `./CivManage`, err => { const webpack = require('webpack');
const chalk = require('chalk');
const ora = require('ora')
const webpackConfig = require('./webpack.prod.babel')
const spinner = ora('building for production...');
// const Diff = require('diff');
/* eslint-disable */
spinner.start()
rm(
process.env.npm_config_releasepath
? path.resolve(
process.env.npm_config_releasepath,
'civmanage',
)
: `./civmanage`,
err => {
if (err) throw err if (err) throw err
// eslint-disable-next-line no-shadow
webpack(webpackConfig, function (err, stats) {
spinner.stop()
if (err) throw err
process.stdout.write(`${stats.toString({
colors: true,
color: true,
progress: true,
modules: false,
children: false,
chunks: true,
chunkModules: true
}) }\n\n`)
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan(' Build complete.\n'))
console.log(
chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
}) })
...@@ -8,8 +8,8 @@ module.exports = options => ({ ...@@ -8,8 +8,8 @@ module.exports = options => ({
entry: options.entry, entry: options.entry,
output: Object.assign( output: Object.assign(
{ {
path: process.env.npm_config_releasepath ? path.resolve(process.env.npm_config_releasepath, 'CivManage'): path.resolve(process.cwd(), 'CivManage'), path: process.env.npm_config_releasepath ? path.resolve(process.env.npm_config_releasepath, 'civmanage'): path.resolve(process.cwd(), 'civmanage'),
publicPath: process.env.PUBLIC_PATH || '/CivManage/', publicPath: process.env.PUBLIC_PATH || '/civmanage/',
}, },
options.output, options.output,
), // Merge with env dependent settings ), // Merge with env dependent settings
...@@ -116,7 +116,7 @@ module.exports = options => ({ ...@@ -116,7 +116,7 @@ module.exports = options => ({
// Inline files smaller than 10 kB // Inline files smaller than 10 kB
limit: 10 * 1024, limit: 10 * 1024,
outputPath: 'assets/', outputPath: 'assets/',
name: '[name].[ext]' // name: '[name].[ext]'
}, },
}, },
// { // {
......
...@@ -19,8 +19,8 @@ module.exports = require('./webpack.base.babel')({ ...@@ -19,8 +19,8 @@ module.exports = require('./webpack.base.babel')({
// Utilize long-term caching by adding content hashes (not compilation hashes) to compiled assets // Utilize long-term caching by adding content hashes (not compilation hashes) to compiled assets
//[chunkhash:8] [chunkhash:8] //[chunkhash:8] [chunkhash:8]
output: { output: {
filename: 'static/[name].js', filename: 'static/[name].[chunkhash:8].js',
chunkFilename: 'static/[name].chunk.js', chunkFilename: 'static/[name].[chunkhash:8].chunk.js',
}, },
optimization: { optimization: {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"analyze": "node ./internals/scripts/analyze.js", "analyze": "node ./internals/scripts/analyze.js",
"npmcheckversion": "node ./internals/scripts/npmcheckversion.js", "npmcheckversion": "node ./internals/scripts/npmcheckversion.js",
"preinstall": "npm run npmcheckversion", "preinstall": "npm run npmcheckversion",
"build": "cross-env NODE_ENV=production webpack --config internals/webpack/webpack.prod.babel.js --color -p --progress --hide-modules --display-optimization-bailout", "build": "cross-env NODE_ENV=production node internals/webpack/clean.js",
"build:inspect": "cross-env NODE_ENV=production node --inspect-brk ./node_modules/webpack/bin/webpack.js --config internals/webpack/webpack.prod.babel.js --color -p --progress --hide-modules --display-optimization-bailout", "build:inspect": "cross-env NODE_ENV=production node --inspect-brk ./node_modules/webpack/bin/webpack.js --config internals/webpack/webpack.prod.babel.js --color -p --progress --hide-modules --display-optimization-bailout",
"build:clean": "node ./internals/webpack/clean.js", "build:clean": "node ./internals/webpack/clean.js",
"start": "cross-env NODE_ENV=development node server", "start": "cross-env NODE_ENV=development node server",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment