Skip to content

Commit 7f4fe00

Browse files
committed
[Project] Update webpack configuration, gulp
1 parent 0e8da3f commit 7f4fe00

File tree

6 files changed

+46
-27
lines changed

6 files changed

+46
-27
lines changed

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"presets":["es2015", "stage-0", "react"]
2+
"presets":["es2015", "stage-0", "react"],
3+
"plugins": ["transform-runtime"]
34
}

gulp/config/webpack-dev.config.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
/* ************************************* */
1010
const path = require('path');
1111
const webpack = require('webpack');
12-
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
1312
const HtmlWebpackPlugin = require('html-webpack-plugin');
1413
const webpackCombineLoaders = require('webpack-combine-loaders');
1514
const autoprefixer = require('autoprefixer');
@@ -25,15 +24,17 @@ const ROOT_DIR = path.resolve(__dirname, '../..');
2524
/* ************************************* */
2625

2726
module.exports = {
27+
bail: true,
28+
devtool: 'source-map',
2829
entry: {
2930
app: [
3031
path.join(APP_DIR, 'index.jsx'),
3132
path.join(APP_DIR, 'index.html'),
3233
],
33-
vendor: ['react', 'react-hotkeys'],
34+
vendor: ['react', 'react-hotkeys', 'react-dom', 'lodash'],
3435
},
3536
resolve: {
36-
extensions: ['', '.scss', '.css', '.js', '.json'],
37+
extensions: ['', '.scss', '.sass', '.css', '.js', '.jsx', '.json'],
3738
},
3839
output: {
3940
path: BUILD_DIR,
@@ -43,7 +44,7 @@ module.exports = {
4344
module: {
4445
preLoaders: [
4546
{
46-
test: /\.js$/,
47+
test: /\.js(x|)$/,
4748
loader: 'eslint',
4849
include: [
4950
SRC_DIR,
@@ -52,7 +53,7 @@ module.exports = {
5253
],
5354
loaders: [
5455
{
55-
test: /\.js?/,
56+
test: /\.js(x|)?/,
5657
exclude: /node_modules/,
5758
loader: 'babel',
5859
},
@@ -113,6 +114,8 @@ module.exports = {
113114
},
114115
eslint: {
115116
configFile: path.join(ROOT_DIR, '.eslintrc.json'),
117+
failOnWarning: true,
118+
failOnError: true,
116119
},
117120
postcss: [
118121
autoprefixer({
@@ -131,9 +134,5 @@ module.exports = {
131134
filename: 'index.html',
132135
template: path.join(APP_DIR, 'index.html'),
133136
}),
134-
//new ProgressBarPlugin(),
135-
new webpack.optimize.DedupePlugin(),
136-
new webpack.HotModuleReplacementPlugin(),
137-
new webpack.NoErrorsPlugin(),
138137
],
139138
};

gulp/config/webpack-prod.config.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ const ROOT_DIR = path.resolve(__dirname, '../..');
2525
/* ************************************* */
2626

2727
module.exports = {
28+
bail: true,
29+
devtool: 'cheap-module-source-map',
2830
entry: {
2931
app: [
3032
path.join(APP_DIR, 'index.jsx'),
3133
path.join(APP_DIR, 'index.html'),
3234
],
33-
vendor: ['react', 'react-hotkeys'],
35+
vendor: ['react', 'react-hotkeys', 'react-dom', 'lodash'],
3436
},
3537
resolve: {
36-
extensions: ['', '.scss', '.css', '.js', '.json'],
38+
extensions: ['', '.scss', '.sass', '.css', '.js', '.jsx', '.json'],
3739
},
3840
output: {
3941
path: BUILD_DIR,
@@ -42,7 +44,7 @@ module.exports = {
4244
module: {
4345
preLoaders: [
4446
{
45-
test: /\.js$/,
47+
test: /\.js(x|)$/,
4648
loader: 'eslint',
4749
include: [
4850
SRC_DIR,
@@ -51,7 +53,7 @@ module.exports = {
5153
],
5254
loaders: [
5355
{
54-
test: /\.js?/,
56+
test: /\.js(x|)$/,
5557
exclude: /node_modules/,
5658
loader: 'babel',
5759
},
@@ -109,6 +111,8 @@ module.exports = {
109111
},
110112
eslint: {
111113
configFile: path.join(ROOT_DIR, '.eslintrc.json'),
114+
failOnWarning: true,
115+
failOnError: true,
112116
},
113117
postcss: [
114118
autoprefixer({
@@ -130,6 +134,13 @@ module.exports = {
130134
new ExtractTextPlugin('[name]-[hash:5].css'),
131135
new webpack.optimize.DedupePlugin(),
132136
new webpack.optimize.OccurrenceOrderPlugin(),
133-
new webpack.optimize.UglifyJsPlugin({}),
137+
new webpack.optimize.UglifyJsPlugin({
138+
compressor: {
139+
warnings: false,
140+
dead_code: true,
141+
unused: true,
142+
},
143+
minimize: true,
144+
}),
134145
],
135146
};

gulp/config/webpack-serve.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,24 @@
99
/* ************************************* */
1010
const fs = require('fs');
1111
const path = require('path');
12+
const webpack = require('webpack');
13+
const WebpackBrowserPlugin = require('webpack-browser-plugin');
1214
const configDev = require('./webpack-dev.config');
1315

1416
const babelrcString = fs.readFileSync(path.resolve(__dirname, '../../.babelrc'));
1517
const babelrc = JSON.parse(babelrcString.toString());
1618

1719
// Update
20+
configDev.bail = false;
1821
configDev.module.preLoaders = [];
1922
configDev.module.loaders[0].query = babelrc;
2023
configDev.module.loaders[0].query.presets.push('react-hmre');
2124
configDev.module.loaders[0].query.babelrc = false;
2225
configDev.entry.app.push('webpack-dev-server/client?http://localhost:8080');
2326
configDev.entry.app.push('webpack/hot/only-dev-server');
27+
configDev.plugins.push(new webpack.NoErrorsPlugin());
28+
configDev.plugins.push(new webpack.HotModuleReplacementPlugin());
29+
configDev.plugins.push(new WebpackBrowserPlugin());
2430

2531
/* ************************************* */
2632
/* ******** EXPORTS ******** */

gulp/web.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
/* ******** REQUIRE ******** */
99
/* ************************************* */
1010
const gulp = require('gulp');
11-
const webpackStream = require('webpack-stream');
1211
const webpack = require('webpack');
1312
const WebpackDevServer = require('webpack-dev-server');
1413

@@ -21,16 +20,19 @@ const WebpackDevServer = require('webpack-dev-server');
2120
/* ******** PUBLIC FUNCTIONS ******** */
2221
/* ************************************* */
2322

24-
gulp.task('web:build:dev', () => {
25-
gulp.src('src/dev/index.jsx')
26-
.pipe(webpackStream(require('./config/webpack-dev.config')))
27-
.pipe(gulp.dest('dev_build/'));
23+
gulp.task('web:build:dev', (done) => {
24+
webpack(require('./config/webpack-dev.config'), done);
2825
});
2926

30-
gulp.task('web:build:prod', () => {
31-
gulp.src('src/dev/index.jsx')
32-
.pipe(webpackStream(require('./config/webpack-prod.config')))
33-
.pipe(gulp.dest('docs/'));
27+
gulp.task('web:build:prod', (done) => {
28+
webpack(require('./config/webpack-prod.config'), (err, stats) => {
29+
if (err) {
30+
return done(err);
31+
}
32+
33+
console.log(stats.toString());
34+
done();
35+
});
3436
});
3537

3638
gulp.task('web:serve', (done) => {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"autoprefixer": "^6.5.3",
2727
"babel-core": "^6.18.2",
2828
"babel-loader": "^6.2.8",
29+
"babel-plugin-transform-runtime": "^6.15.0",
2930
"babel-preset-es2015": "^6.13.2",
3031
"babel-preset-react": "^6.11.1",
3132
"babel-preset-react-hmre": "^1.1.1",
@@ -48,7 +49,6 @@
4849
"lodash": "^4.17.2",
4950
"node-sass": "^3.13.0",
5051
"postcss-loader": "^1.1.1",
51-
"progress-bar-webpack-plugin": "^1.9.0",
5252
"react": "^15.4.0",
5353
"react-dom": "^15.4.0",
5454
"react-hot-loader": "^1.3.0",
@@ -57,9 +57,9 @@
5757
"style-loader": "^0.13.1",
5858
"url-loader": "^0.5.7",
5959
"webpack": "^1.13.2",
60+
"webpack-browser-plugin": "^1.0.12",
6061
"webpack-combine-loaders": "^2.0.3",
61-
"webpack-dev-server": "^1.14.1",
62-
"webpack-stream": "^3.2.0"
62+
"webpack-dev-server": "^1.14.1"
6363
},
6464
"peerDependencies": {
6565
"react": "^15.4.0",

0 commit comments

Comments
 (0)