Authored by 陈峰

docker

... ... @@ -12,4 +12,5 @@ app/bundle
.happypack/
build/dll/
server/bundle/*.json
server/bundle/**/
\ No newline at end of file
server/bundle/**/
dist
... ...
... ... @@ -6,8 +6,8 @@ module.exports = {
env: {
NODE_ENV: '"production"'
},
index: path.resolve(__dirname, `../public/dist/${pkg.name}/${pkg.version}/index.html`),
assetsRoot: path.resolve(__dirname, `../public/dist/${pkg.name}/`),
index: path.resolve(__dirname, `../dist/statics/${pkg.name}/${pkg.version}/index.html`),
assetsRoot: path.resolve(__dirname, `../dist/statics/${pkg.name}/`),
assetsSubDirectory: 'static',
assetsPublicPath: '//cdn.yoho.cn/yoho-shop-manage/',
productionSourceMap: true,
... ...
const shelljs = require('shelljs');
const path = require('path');
const distDir = path.join(__dirname, '../dist/node');
shelljs.rm('-rf', distDir);
shelljs.mkdir('-p', distDir);
const cpPaths = [
'.npmrc',
'process.json',
'Dockerfile',
'yarn.lock',
'package.json',
'server',
'manifest.json'
];
new Promise(resolve => { // 加载manifest.json文件
resolve();
}).then(() => { // 拷贝node代码
cpPaths.forEach(p => {
let dist = distDir;
let file = p;
if (typeof p === 'object') {
dist = path.join(dist, p[1]);
file = p[0];
if (!shelljs.test('-e', dist)) {
shelljs.mkdir('-p', dist);
}
}
shelljs.cp('-R', path.join(__dirname, '../', file), dist);
});
}).then(() => { // 安装依赖和清理node_modules
shelljs.cd(distDir);
if (shelljs.exec('yarn --production=true').code !== 0) {
throw 'yarn install faild';
}
}).catch(error => {
console.error(`error:${error}`);
return process.exit(1); //eslint-disable-line
});
... ...
{}
\ No newline at end of file
... ...
This diff could not be displayed because it is too large.
... ... @@ -8,6 +8,7 @@
"dev": "nodemon --watch server server/app.js",
"static": "node ./build/dev-server.js",
"dist": "node ./build/build.js",
"build:node": "node ./build/node-build.js",
"build": "npm run build:dll --production && node ./build/build.js",
"build:dll": "rimraf build/dll && webpack --config build/webpack.dll.conf.js",
"lint-js": "lint-js",
... ...