Skip to content

Commit

Permalink
webpack client build namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
foxhound87 committed Dec 8, 2016
1 parent 2fc8968 commit b173d7b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/web/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
</head>
<body>
<div id="root"><%-root%></div>
<script src="<%-build%>/vendor.bundle.js"></script>
<script src="<%-build%>/bundle.js"></script>
<% if (build) { %>
<script src="<%-build%>/web.vendor.bundle.js"></script>
<script src="<%-build%>/web.app.bundle.js"></script>
<% } else { %>
<script src="bundle.js"></script>
<% } %>
</body>
</html>
2 changes: 1 addition & 1 deletion webpack.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (match.script('build:client:web', 'production')) {
Config = require('./webpack/config.client').load();
const ConfigClientBuild = require('./webpack/config.client.build');
Loader = merge(Loader, ConfigClientBuild.loader());
Config = merge(Config, ConfigClientBuild.config());
Config = merge(Config, ConfigClientBuild.config('web'));
}

if (match.script('build:server:web', 'production')) {
Expand Down
9 changes: 7 additions & 2 deletions webpack/config.client.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function loader() {
};
}

export function config() {
export function config(entry) {
return {
bail: true,
devtool: 'source-map',
Expand All @@ -55,7 +55,7 @@ export function config() {
output: {
path: path.join(Dir.public, 'build'),
publicPath: '/build/',
filename: 'bundle.js',
filename: [entry, 'app', 'bundle', 'js'].join('.'),
},
plugins: [
new ProgressBarPlugin(),
Expand All @@ -67,6 +67,11 @@ export function config() {
warnings: false,
},
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
filename: [entry, 'vendor', 'bundle', 'js'].join('.'),
}),
new ExtractTextPlugin({
filename: 'style.css',
allChunks: true,
Expand Down
2 changes: 0 additions & 2 deletions webpack/config.client.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import webpack from 'webpack';
import getenv from 'getenv';
import path from 'path';

import vendor from '~/config/vendor';
import { logServerConfig } from '@/utils/logger';

const Dir = global.DIR;
Expand Down Expand Up @@ -42,7 +41,6 @@ export function config() {
return {
devtool: 'cheap-module-eval-source-map',
entry: {
vendor,
app: [
'babel-polyfill',
'isomorphic-fetch',
Expand Down
5 changes: 0 additions & 5 deletions webpack/config.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ export function load() {
return {
target: 'web',
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
filename: 'vendor.bundle.js',
}),
new webpack.DefinePlugin({
'global.DIR': JSON.stringify(global.DIR),
'global.CONFIG': JSON.stringify(getenv.multi(env)),
Expand Down

0 comments on commit b173d7b

Please sign in to comment.