Skip to content

Commit 4af7bf6

Browse files
committed
Cleanup webpack configs
1 parent 1c5b6e3 commit 4af7bf6

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

webpack.build.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
var path = require('path');
2-
var webpack = require('webpack');
3-
var BASE_DIR = process.cwd();
4-
var COMPONENT_FILE = 'react-tabs';
5-
var COMPONENT_NAME = 'ReactTabs';
6-
var plugins = [];
1+
'use strict';
72

8-
function getPackageMain() {
9-
return require(path.resolve(BASE_DIR, 'package.json')).main;
10-
}
3+
const path = require('path');
4+
const webpack = require('webpack');
5+
6+
let COMPONENT_FILE = 'react-tabs';
7+
const plugins = [];
118

129
if (process.env.MINIFY) {
1310
plugins.push(
@@ -17,34 +14,34 @@ if (process.env.MINIFY) {
1714
}
1815

1916
module.exports = {
20-
entry: path.resolve(BASE_DIR, getPackageMain()),
17+
entry: path.join(__dirname, require(path.join(__dirname, 'package.json')).main),
2118
output: {
22-
filename: path.resolve(BASE_DIR, 'dist/' + COMPONENT_FILE + '.js'),
23-
library: COMPONENT_NAME,
24-
libraryTarget: 'umd'
19+
filename: path.join(__dirname, 'dist/' + COMPONENT_FILE + '.js'),
20+
library: 'ReactTabs',
21+
libraryTarget: 'umd',
2522
},
2623
externals: {
2724
'react': {
2825
root: 'React',
2926
commonjs2: 'react',
3027
commonjs: 'react',
31-
amd: 'react'
28+
amd: 'react',
3229
},
3330
'react-dom': {
3431
root: 'ReactDOM',
3532
commonjs2: 'react-dom',
3633
commonjs: 'react-dom',
37-
amd: 'react-dom'
38-
}
34+
amd: 'react-dom',
35+
},
3936
},
4037
module: {
4138
loaders: [
4239
{
4340
test: /\.js$/,
4441
exclude: /node_modules/,
45-
loader: 'babel-loader'
46-
}
47-
]
42+
loader: 'babel-loader',
43+
},
44+
],
4845
},
49-
plugins: plugins
46+
plugins: plugins,
5047
};

webpack.config.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
var fs = require('fs');
2-
var path = require('path');
3-
var webpack = require('webpack');
4-
var EXAMPLES_DIR = path.resolve(process.cwd(), 'examples');
1+
'use strict';
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const webpack = require('webpack');
6+
7+
const EXAMPLES_DIR = path.join(__dirname, 'examples');
58

69
function buildEntries() {
710
return fs.readdirSync(EXAMPLES_DIR).reduce(function (entries, dir) {
811
if (dir === 'build') {
912
return entries;
1013
}
1114

12-
var isDraft = dir.charAt(0) === '_';
13-
var isDirectory = fs.lstatSync(path.join(EXAMPLES_DIR, dir)).isDirectory();
15+
const isDraft = dir.charAt(0) === '_';
16+
const isDirectory = fs.lstatSync(path.join(EXAMPLES_DIR, dir)).isDirectory();
1417

1518
if (!isDraft && isDirectory) {
1619
entries[dir] = path.join(EXAMPLES_DIR, dir, 'app.js');
@@ -28,21 +31,21 @@ module.exports = {
2831
filename: '[name].js',
2932
chunkFilename: '[id].chunk.js',
3033
path: 'examples/__build__',
31-
publicPath: '/__build__/'
34+
publicPath: '/__build__/',
3235
},
3336

3437
module: {
3538
loaders: [
3639
{
3740
test: /\.js$/,
3841
exclude: /node_modules/,
39-
loader: 'babel-loader'
40-
}
41-
]
42+
loader: 'babel-loader',
43+
},
44+
],
4245
},
4346

4447
plugins: [
45-
new webpack.optimize.CommonsChunkPlugin('shared.js')
48+
new webpack.optimize.CommonsChunkPlugin('shared.js'),
4649
]
4750

4851
};

0 commit comments

Comments
 (0)