Showing
6 changed files
with
57 additions
and
3 deletions
@@ -6,8 +6,8 @@ module.exports = { | @@ -6,8 +6,8 @@ module.exports = { | ||
6 | env: { | 6 | env: { |
7 | NODE_ENV: '"production"' | 7 | NODE_ENV: '"production"' |
8 | }, | 8 | }, |
9 | - index: path.resolve(__dirname, `../public/dist/${pkg.name}/${pkg.version}/index.html`), | ||
10 | - assetsRoot: path.resolve(__dirname, `../public/dist/${pkg.name}/`), | 9 | + index: path.resolve(__dirname, `../dist/statics/${pkg.name}/${pkg.version}/index.html`), |
10 | + assetsRoot: path.resolve(__dirname, `../dist/statics/${pkg.name}/`), | ||
11 | assetsSubDirectory: 'static', | 11 | assetsSubDirectory: 'static', |
12 | assetsPublicPath: '//cdn.yoho.cn/yoho-shop-manage/', | 12 | assetsPublicPath: '//cdn.yoho.cn/yoho-shop-manage/', |
13 | productionSourceMap: true, | 13 | productionSourceMap: true, |
build/node-build.js
0 → 100644
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 | + '.npmrc', | ||
11 | + 'process.json', | ||
12 | + 'Dockerfile', | ||
13 | + 'yarn.lock', | ||
14 | + 'package.json', | ||
15 | + 'server', | ||
16 | + 'manifest.json' | ||
17 | +]; | ||
18 | + | ||
19 | +new Promise(resolve => { // 加载manifest.json文件 | ||
20 | + resolve(); | ||
21 | +}).then(() => { // 拷贝node代码 | ||
22 | + cpPaths.forEach(p => { | ||
23 | + let dist = distDir; | ||
24 | + let file = p; | ||
25 | + | ||
26 | + if (typeof p === 'object') { | ||
27 | + dist = path.join(dist, p[1]); | ||
28 | + file = p[0]; | ||
29 | + | ||
30 | + if (!shelljs.test('-e', dist)) { | ||
31 | + shelljs.mkdir('-p', dist); | ||
32 | + } | ||
33 | + } | ||
34 | + shelljs.cp('-R', path.join(__dirname, '../', file), dist); | ||
35 | + }); | ||
36 | +}).then(() => { // 安装依赖和清理node_modules | ||
37 | + | ||
38 | + shelljs.cd(distDir); | ||
39 | + if (shelljs.exec('yarn --production=true').code !== 0) { | ||
40 | + throw 'yarn install faild'; | ||
41 | + } | ||
42 | +}).catch(error => { | ||
43 | + console.error(`error:${error}`); | ||
44 | + return process.exit(1); //eslint-disable-line | ||
45 | +}); | ||
46 | + | ||
47 | + | ||
48 | + | ||
49 | + | ||
50 | + | ||
51 | + |
manifest.json
0 → 100644
1 | +{} |
package-lock.json
deleted
100644 → 0
This diff could not be displayed because it is too large.
@@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
8 | "dev": "nodemon --watch server server/app.js", | 8 | "dev": "nodemon --watch server server/app.js", |
9 | "static": "node ./build/dev-server.js", | 9 | "static": "node ./build/dev-server.js", |
10 | "dist": "node ./build/build.js", | 10 | "dist": "node ./build/build.js", |
11 | + "build:node": "node ./build/node-build.js", | ||
11 | "build": "npm run build:dll --production && node ./build/build.js", | 12 | "build": "npm run build:dll --production && node ./build/build.js", |
12 | "build:dll": "rimraf build/dll && webpack --config build/webpack.dll.conf.js", | 13 | "build:dll": "rimraf build/dll && webpack --config build/webpack.dll.conf.js", |
13 | "lint-js": "lint-js", | 14 | "lint-js": "lint-js", |
-
Please register or login to post a comment