Authored by 陈峰

Merge branch 'feature/build' into 'release/6.8.5'

build change



See merge request !419
@@ -9,9 +9,10 @@ @@ -9,9 +9,10 @@
9 }, 9 },
10 "scripts": { 10 "scripts": {
11 "start": "node app.js", 11 "start": "node app.js",
12 - "dev": "nodemon -e js,hbs -i public/ app.js", 12 + "dev": "nodemon -e js,hbs -i public/ -i dist/ app.js",
13 "static": "webpack-dev-server --config ./public/build/webpack.dev.config.js", 13 "static": "webpack-dev-server --config ./public/build/webpack.dev.config.js",
14 "build": "webpack --config ./public/build/webpack.prod.config.js", 14 "build": "webpack --config ./public/build/webpack.prod.config.js",
  15 + "build:node": "node ./public/build/node-build.js",
15 "online": "NODE_ENV=\"production\" node app.js", 16 "online": "NODE_ENV=\"production\" node app.js",
16 "debug": "DEBUG=\"express:*\" nodemon -e js,hbs -i public/ app.js", 17 "debug": "DEBUG=\"express:*\" nodemon -e js,hbs -i public/ app.js",
17 "lint-js": "eslint -c .eslintrc --cache --fix .", 18 "lint-js": "eslint -c .eslintrc --cache --fix .",
  1 +const shelljs = require('shelljs');
  2 +const path = require('path');
  3 +
  4 +const distDir = path.join(__dirname, '../../dist/node');
  5 +
  6 +shelljs.rm('-rf', distDir);
  7 +shelljs.mkdir('-p', distDir);
  8 +
  9 +const cpPaths = [
  10 + 'favicon.ico',
  11 + '.npmrc',
  12 + 'process.json',
  13 + 'Dockerfile',
  14 + 'yarn.lock',
  15 + 'package.json',
  16 + '*.js',
  17 + 'config',
  18 + 'apps',
  19 + 'doraemon',
  20 + 'mix',
  21 + 'utils',
  22 + 'static',
  23 + 'manifest.json'
  24 +];
  25 +
  26 +new Promise(resolve => { // 加载manifest.json文件
  27 + resolve();
  28 +}).then(() => { // 拷贝node代码
  29 + cpPaths.forEach(p => {
  30 + let dist = distDir;
  31 + let file = p;
  32 +
  33 + if (typeof p === 'object') {
  34 + dist = path.join(dist, p[1]);
  35 + file = p[0];
  36 +
  37 + if (!shelljs.test('-e', dist)) {
  38 + shelljs.mkdir('-p', dist);
  39 + }
  40 + }
  41 + shelljs.cp('-R', path.join(__dirname, '../../', file), dist);
  42 + });
  43 +}).then(() => { // 安装依赖和清理node_modules
  44 + shelljs.cd(distDir);
  45 + if (shelljs.exec('yarn --production=true').code !== 0) {
  46 + throw 'yarn install faild';
  47 + }
  48 +}).catch(error => {
  49 + console.error(`error:${error}`);
  50 + return process.exit(1); //eslint-disable-line
  51 +});
  52 +
  53 +
  54 +
  55 +
  56 +
  57 +
@@ -18,7 +18,7 @@ const opacity = require('postcss-opacity'); @@ -18,7 +18,7 @@ const opacity = require('postcss-opacity');
18 const spritescore = require('postcss-sprites/lib/core'); 18 const spritescore = require('postcss-sprites/lib/core');
19 const config = require('../../package.json'); 19 const config = require('../../package.json');
20 const devInfo = require('./dev-info.js'); 20 const devInfo = require('./dev-info.js');
21 -const distDir = path.join(__dirname, `../dist/${config.name}/${config.version}`); 21 +const distDir = path.join(__dirname, `../../dist/statics/${config.name}/${config.version}`);
22 const dist = { 22 const dist = {
23 img: distDir + '/img', 23 img: distDir + '/img',
24 font: distDir + '/font' 24 font: distDir + '/font'
@@ -5,7 +5,7 @@ const shelljs = require('shelljs'); @@ -5,7 +5,7 @@ const shelljs = require('shelljs');
5 const _ = require('lodash'); 5 const _ = require('lodash');
6 const ExtractTextPlugin = require('extract-text-webpack-plugin'); 6 const ExtractTextPlugin = require('extract-text-webpack-plugin');
7 const config = require('../../package.json'); 7 const config = require('../../package.json');
8 -const distDir = path.join(__dirname, `../dist/${config.name}/${config.version}`); 8 +const distDir = path.join(__dirname, `../../dist/statics/${config.name}/${config.version}`);
9 let baseConfig = require('./webpack.base.config.js'); 9 let baseConfig = require('./webpack.base.config.js');
10 10
11 // cope img font 11 // cope img font