Skip to content

Commit

Permalink
[feat]: update ENV for production
Browse files Browse the repository at this point in the history
  • Loading branch information
展新 committed Feb 4, 2016
1 parent 2a9ef18 commit 1f17540
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ Thumbs.db
node_modules
dist
build/
public/
6 changes: 3 additions & 3 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

const pkg = require('../../package.json');
const stats = require("../../build/stats.json");
const publicPath = stats.publicPath;
var STYLE_URL;
var SCRIPT_URL_APP = publicPath + [].concat(stats.assetsByChunkName.app)[0];
if (process.env.NODE_ENV === "production") {
STYLE_URL = (publicPath + [].concat(stats.assetsByChunkName.app)[1] + "?" + stats.hash);
SCRIPT_URL_APP += "?" + stats.hash;
STYLE_URL = '/' + pkg.version + '/' + (publicPath + [].concat(stats.assetsByChunkName.app)[1] + "?" + stats.hash);
SCRIPT_URL_APP = '/' + pkg.version + '/' + SCRIPT_URL_APP + "?" + stats.hash;
}


Expand Down
2 changes: 1 addition & 1 deletion config/koa.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function(app, config) {
app.use(errorHandler());

if (config.app.env === "production") {
app.use(serve(path.join(config.app.root, "build", "public"), SERVE_OPTIONS, STATIC_FILES_MAP));
app.use(serve(path.join(config.app.root, "public"), SERVE_OPTIONS, STATIC_FILES_MAP));
} else {
app.use(require("koa-proxy")({
host: "http://localhost:2992",
Expand Down
3 changes: 2 additions & 1 deletion webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from "lodash";
import webpack from "webpack";
import strategies from "./strategies";
import yargs from "yargs";
import pkg from '../package.json';

const argv = yargs
.alias("p", "optimize-minimize")
Expand Down Expand Up @@ -39,7 +40,7 @@ export default (options) => {
app: './src/entry/App.jsx'
},
output: {
path: "./build/public",
path: "./public/" + pkg.version,
filename: "[name].js",
chunkFilename: chunkFilename,
publicPath: options.publicPath,
Expand Down

0 comments on commit 1f17540

Please sign in to comment.