File tree Expand file tree Collapse file tree 8 files changed +76
-28
lines changed
Expand file tree Collapse file tree 8 files changed +76
-28
lines changed Original file line number Diff line number Diff line change 22
33process . env . DEBUG = 'pixore:front-scripts, pixore:error'
44
5- const { input} = require ( 'parse-cmd-args' ) ( )
5+ const { input } = require ( 'parse-cmd-args' ) ( )
66const debug = require ( 'debug' ) ( 'pixore:front-scripts' )
77
88switch ( input ) {
Original file line number Diff line number Diff line change 1+ {
2+ // See http://go.microsoft.com/fwlink/?LinkId=759670
3+ // for the documentation about the jsconfigon format
4+ "compilerOptions" : {
5+ "module" : " es6" ,
6+ "target" : " es6" ,
7+ "noLib" : true
8+ },
9+ "exclude" : [
10+ " node_modules" ,
11+ " bower_components" ,
12+ " jspm_packages" ,
13+ " tmp" ,
14+ " temp"
15+ ]
16+ }
Original file line number Diff line number Diff line change 2323 "babel-plugin-transform-object-rest-spread" : " ^6.23.0" ,
2424 "babel-preset-es2015" : " ^6.24.1" ,
2525 "babel-preset-react" : " ^6.24.1" ,
26+ "babel-register" : " ^6.24.1" ,
2627 "bluebird" : " ^3.5.0" ,
2728 "chalk" : " ^1.1.3" ,
2829 "connect-history-api-fallback" : " ^1.3.0" ,
3334 "exports-loader" : " ^0.6.4" ,
3435 "extract-text-webpack-plugin" : " ^2.1.2" ,
3536 "file-loader" : " ^0.11.2" ,
37+ "glob" : " ^7.1.2" ,
3638 "html-webpack-plugin" : " ^2.28.0" ,
3739 "image-webpack-loader" : " ^3.3.1" ,
3840 "imports-loader" : " ^0.7.1" ,
Original file line number Diff line number Diff line change 11
2+ const { isTest } = require ( './environment' )
3+
24module . exports = {
35 plugins : [
46 require . resolve ( 'babel-plugin-transform-object-rest-spread' ) ,
@@ -8,7 +10,7 @@ module.exports = {
810 [
911 require . resolve ( 'babel-preset-es2015' ) ,
1012 {
11- 'modules' : false
13+ 'modules' : isTest ? 'commonjs' : true
1214 }
1315 ] ,
1416 require . resolve ( 'babel-preset-react' )
Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ const webpackConfig = require('./webpack.config')
44
55webpackConfig . devtool = 'cheap-module-source-map'
66webpackConfig . watch = true
7+ Object . assign ( webpackConfig . externals , {
8+ 'react/lib/ExecutionEnvironment' : true ,
9+ 'react/addons' : true ,
10+ 'react/lib/ReactContext' : 'window'
11+ } )
712
813const testPath = require . resolve ( './tests.webpack.js' )
914module . exports = config => {
Original file line number Diff line number Diff line change 11
2- const context = require . context ( process . env . pwd , true , / .+ ( _ _ t e s t s _ _ \/ ) .+ \. s p e c \. j s ? $ / )
2+ const context = require . context ( process . env . pwd , true , / s r c \/ .+ ( \/ _ _ t e s t s _ _ \/ ) .+ \. s p e c \. j s ? $ / )
33
44context . keys ( ) . forEach ( context )
Original file line number Diff line number Diff line change @@ -21,15 +21,10 @@ const plugins = [
2121let devtool
2222let entry
2323let devServer
24- const externals = [ ]
24+ const externals = { }
2525
2626const modules = {
2727 rules : [ {
28- test : / \. j s $ / ,
29- loader : 'eslint-loader' ,
30- enforce : 'pre' ,
31- exclude : / n o d e _ m o d u l e s | w e b p a c k H o t D e v C l i e n t /
32- } , {
3328 test : / \. j s $ / ,
3429 exclude : / n o d e _ m o d u l e s / ,
3530 loader : 'babel-loader' ,
@@ -83,6 +78,28 @@ const output = {
8378 filename : isProd ? '[name].[chunkhash].js' : 'build.js'
8479}
8580
81+ if ( isDev ) {
82+ modules . rules = [ {
83+ test : / \. j s $ / ,
84+ loader : 'eslint-loader' ,
85+ enforce : 'pre' ,
86+ exclude : / n o d e _ m o d u l e s | w e b p a c k H o t D e v C l i e n t /
87+ } ] . concat ( modules . rules )
88+ plugins . push (
89+ new webpack . LoaderOptionsPlugin ( {
90+ test : / \. j s $ / ,
91+ options : {
92+ eslint : {
93+ options : {
94+ cacheDirectory : true ,
95+ configFile : ESLINT_PATH
96+ }
97+ }
98+ }
99+ } )
100+ )
101+ }
102+
86103if ( isProd ) {
87104 entry = {
88105 index : APP_PATH
@@ -115,17 +132,6 @@ if (isProd) {
115132 ]
116133 devtool = 'source-map'
117134 plugins . push (
118- new webpack . LoaderOptionsPlugin ( {
119- test : / \. j s $ / ,
120- options : {
121- eslint : {
122- options : {
123- cacheDirectory : true ,
124- configFile : ESLINT_PATH
125- }
126- }
127- }
128- } ) ,
129135 new HtmlWebpackPlugin ( {
130136 title : 'Pixore' ,
131137 filename : 'index.html' ,
Original file line number Diff line number Diff line change 11process . env . NODE_ENV = 'test'
2-
2+ const glob = require ( 'glob' )
3+ const { flags } = require ( 'parse-cmd-args' ) ( )
4+ const Mocha = require ( 'mocha' )
35const Server = require ( 'karma' ) . Server
46const debug = require ( 'debug' ) ( 'pixore:front-scripts' )
57
8+ const babelConfig = require ( '../config/babelrc.js' )
69const { validStructure } = require ( '../utils' )
710const karmaConfig = require . resolve ( '../config/karma.conf.js' )
811
912validStructure ( )
1013
11- const server = new Server ( {
12- configFile : karmaConfig
13- } , ( exitCode ) => {
14- debug ( 'Karma has exited with ' + exitCode )
15- process . exit ( exitCode )
16- } )
14+ const withKarma = flags [ '--karma' ]
1715
18- server . start ( )
16+ if ( withKarma ) {
17+ const server = new Server ( {
18+ configFile : karmaConfig
19+ } , ( exitCode ) => {
20+ debug ( 'Karma has exited with ' + exitCode )
21+ process . exit ( exitCode )
22+ } )
23+ server . start ( )
24+ } else {
25+ require ( 'babel-register' ) ( babelConfig )
26+ const mocha = new Mocha ( )
27+ glob ( 'src/**/__tests__/*.spec.js' , function ( err , files ) {
28+ if ( err ) {
29+ debug ( err )
30+ process . exit ( 1 )
31+ }
32+ files . forEach ( ( file ) => mocha . addFile ( file ) )
33+ mocha . run ( failures => process . on ( 'exit' , ( ) => process . exit ( failures ) ) )
34+ } )
35+ }
You can’t perform that action at this time.
0 commit comments