Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit ac60a3c

Browse files
Merge pull request #138 from johnnyreilly/master
updated react-flux-babel-karma to webpack 2
2 parents 2350e25 + 6078824 commit ac60a3c

File tree

5 files changed

+57
-35
lines changed

5 files changed

+57
-35
lines changed

react-flux-babel-karma/gulp/webpack.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var packageJson = require('../package.json');
1010

1111
function buildProduction(done) {
1212
// modify some webpack config options
13-
var myProdConfig = Object.create(webpackConfig);
13+
var myProdConfig = webpackConfig;
1414
myProdConfig.output.filename = '[name].[hash].js';
1515

1616
myProdConfig.plugins = myProdConfig.plugins.concat(
@@ -20,8 +20,11 @@ function buildProduction(done) {
2020
}
2121
}),
2222
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.[hash].js' }),
23-
new webpack.optimize.DedupePlugin(),
24-
new webpack.optimize.UglifyJsPlugin(),
23+
new webpack.optimize.UglifyJsPlugin({
24+
compress: {
25+
warnings: true
26+
}
27+
}),
2528
failPlugin
2629
);
2730

@@ -38,9 +41,8 @@ function buildProduction(done) {
3841

3942
function createDevCompiler() {
4043
// modify some webpack config options
41-
var myDevConfig = Object.create(webpackConfig);
44+
var myDevConfig = webpackConfig;
4245
myDevConfig.devtool = 'inline-source-map';
43-
myDevConfig.debug = true;
4446

4547
myDevConfig.plugins = myDevConfig.plugins.concat(
4648
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.js' }),
@@ -73,13 +75,13 @@ function watch() {
7375
}, function (err, stats) {
7476
if (err) {
7577
if (!firstBuildDone) {
76-
firstBuildDone = true;
78+
firstBuildDone = true;
7779
reject(err);
7880
}
7981
throw new gutil.PluginError('webpack:build-dev', err);
8082
} else {
8183
if (!firstBuildDone) {
82-
firstBuildDone = true;
84+
firstBuildDone = true;
8385
resolve('webpack built');
8486
}
8587
}
@@ -95,4 +97,4 @@ function watch() {
9597
module.exports = {
9698
build: function () { return build(); },
9799
watch: function () { return watch(); }
98-
};
100+
};

react-flux-babel-karma/gulpFile.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@ gulp.task('delete-dist', function (done) {
1616
clean.run(done);
1717
});
1818

19-
gulp.task('build-process.env.NODE_ENV', function () {
20-
process.env.NODE_ENV = 'production';
21-
});
22-
23-
gulp.task('build-js', ['delete-dist', 'build-process.env.NODE_ENV'], function(done) {
19+
gulp.task('build-js', ['delete-dist'], function(done) {
2420
webpack.build().then(function() { done(); });
2521
});
2622

27-
gulp.task('build-other', ['delete-dist', 'build-process.env.NODE_ENV'], function() {
23+
gulp.task('build-other', ['delete-dist'], function() {
2824
staticFiles.build();
2925
});
3026

react-flux-babel-karma/karma.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ module.exports = function(config) {
2626

2727
webpack: {
2828
devtool: 'inline-source-map',
29-
debug: true,
3029
module: webpackConfig.module,
3130
resolve: webpackConfig.resolve
3231
},

react-flux-babel-karma/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "es6-babel-react-flux-karma",
2+
"name": "react-flux-babel-karma",
33
"version": "1.0.0",
44
"description": "ES6 + TypeScript + Babel + React + Karma: The Secret Recipe",
55
"main": "index.js",
@@ -14,17 +14,18 @@
1414
"url": "git+https://github.com/microsoft/typescriptsamples.git"
1515
},
1616
"keywords": [
17-
"React",
18-
"Flux",
19-
"ES2016",
20-
"typescript"
17+
"react",
18+
"flux",
19+
"es2016",
20+
"typescript",
21+
"webpack"
2122
],
2223
"author": "John Reilly",
2324
"license": "MIT",
2425
"bugs": {
2526
"url": "https://github.com/microsoft/typescriptsamples/issues"
2627
},
27-
"homepage": "https://github.com/Microsoft/TypeScriptSamples/tree/master/es6-babel-react-flux-karma#readme",
28+
"homepage": "https://github.com/Microsoft/TypeScriptSamples/tree/master/react-flux-babel-karma#readme",
2829
"devDependencies": {
2930
"@types/fbemitter": "^2.0.32",
3031
"@types/flux": "0.0.32",
@@ -57,18 +58,17 @@
5758
"gulp-util": "^3.0.6",
5859
"jasmine-core": "^2.3.4",
5960
"karma": "^1.2.0",
60-
"karma-coverage": "^1.0.0",
6161
"karma-jasmine": "^1.0.0",
6262
"karma-junit-reporter": "^1.0.0",
6363
"karma-mocha-reporter": "^2.0.0",
6464
"karma-notify-reporter": "^1.0.0",
6565
"karma-phantomjs-launcher": "^1.0.0",
6666
"karma-sourcemap-loader": "^0.3.6",
67-
"karma-webpack": "^1.7.0",
67+
"karma-webpack": "^2.0.2",
6868
"phantomjs-prebuilt": "^2.1.4",
69-
"ts-loader": "^1.3.1",
69+
"ts-loader": "^2.0.1",
7070
"typescript": "^2.1.4",
71-
"webpack": "^1.12.2",
71+
"webpack": "^2.2.1",
7272
"webpack-fail-plugin": "^1.0.4",
7373
"webpack-notifier": "^1.2.1"
7474
},

react-flux-babel-karma/webpack.config.js

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,31 @@
33

44
var path = require('path');
55

6+
7+
var babelOptions = {
8+
"presets": [
9+
"react",
10+
[
11+
"es2015",
12+
{
13+
"modules": false
14+
}
15+
],
16+
"es2016"
17+
]
18+
};
19+
620
module.exports = {
721
cache: true,
822
entry: {
923
main: './src/main.tsx',
1024
vendor: [
1125
'babel-polyfill',
1226
'events',
27+
'fbemitter',
1328
'flux',
14-
'react'
29+
'react',
30+
'react-dom'
1531
]
1632
},
1733
output: {
@@ -20,23 +36,32 @@ module.exports = {
2036
chunkFilename: '[chunkhash].js'
2137
},
2238
module: {
23-
loaders: [{
39+
rules: [{
2440
test: /\.ts(x?)$/,
2541
exclude: /node_modules/,
26-
loader: 'babel-loader?presets[]=es2016&presets[]=es2015&presets[]=react!ts-loader'
42+
use: [
43+
{
44+
loader: 'babel-loader',
45+
options: babelOptions
46+
},
47+
{
48+
loader: 'ts-loader'
49+
}
50+
]
2751
}, {
2852
test: /\.js$/,
2953
exclude: /node_modules/,
30-
loader: 'babel',
31-
query: {
32-
presets: ['es2016', 'es2015', 'react']
33-
}
54+
use: [
55+
{
56+
loader: 'babel-loader',
57+
options: babelOptions
58+
}
59+
]
3460
}]
3561
},
3662
plugins: [
3763
],
3864
resolve: {
39-
// Add `.ts` and `.tsx` as a resolvable extension.
40-
extensions: ['', '.ts', '.tsx', '.js']
65+
extensions: ['.ts', '.tsx', '.js']
4166
},
42-
};
67+
};

0 commit comments

Comments
 (0)