File tree Expand file tree Collapse file tree 4 files changed +44
-15
lines changed Expand file tree Collapse file tree 4 files changed +44
-15
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ var paths = require('./paths');
1616module . exports = {
1717 devtool : 'eval' ,
1818 entry : [
19- require . resolve ( 'webpack-dev-server/client' ) ,
19+ require . resolve ( 'webpack-dev-server/client' ) + '?/' ,
2020 require . resolve ( 'webpack/hot/dev-server' ) ,
2121 require . resolve ( './polyfills' ) ,
2222 path . join ( paths . appSrc , 'index' )
@@ -25,7 +25,7 @@ module.exports = {
2525 // Next line is not used in dev but WebpackDevServer crashes without it:
2626 path : paths . appBuild ,
2727 pathinfo : true ,
28- filename : 'bundle.js' ,
28+ filename : 'static/js/ bundle.js' ,
2929 publicPath : '/'
3030 } ,
3131 resolve : {
@@ -75,11 +75,18 @@ module.exports = {
7575 test : / \. ( j p g | p n g | g i f | e o t | s v g | t t f | w o f f | w o f f 2 ) $ / ,
7676 include : [ paths . appSrc , paths . appNodeModules ] ,
7777 loader : 'file' ,
78+ query : {
79+ name : 'static/media/[name].[ext]'
80+ }
7881 } ,
7982 {
8083 test : / \. ( m p 4 | w e b m ) $ / ,
8184 include : [ paths . appSrc , paths . appNodeModules ] ,
82- loader : 'url?limit=10000'
85+ loader : 'url' ,
86+ query : {
87+ limit : 10000 ,
88+ name : 'static/media/[name].[ext]'
89+ }
8390 }
8491 ]
8592 } ,
Original file line number Diff line number Diff line change @@ -31,8 +31,8 @@ module.exports = {
3131 ] ,
3232 output : {
3333 path : paths . appBuild ,
34- filename : '[name].[chunkhash:8].js' ,
35- chunkFilename : '[name].[chunkhash:8].chunk.js' ,
34+ filename : 'static/js/ [name].[chunkhash:8].js' ,
35+ chunkFilename : 'static/js/ [name].[chunkhash:8].chunk.js' ,
3636 publicPath : publicPath
3737 } ,
3838 resolve : {
@@ -86,13 +86,17 @@ module.exports = {
8686 include : [ paths . appSrc , paths . appNodeModules ] ,
8787 loader : 'file' ,
8888 query : {
89- name : '[name].[hash:8].[ext]'
89+ name : 'static/media/ [name].[hash:8].[ext]'
9090 }
9191 } ,
9292 {
9393 test : / \. ( m p 4 | w e b m ) $ / ,
9494 include : [ paths . appSrc , paths . appNodeModules ] ,
95- loader : 'url?limit=10000'
95+ loader : 'url' ,
96+ query : {
97+ limit : 10000 ,
98+ name : 'static/media/[name].[hash:8].[ext]'
99+ }
96100 }
97101 ]
98102 } ,
@@ -139,6 +143,6 @@ module.exports = {
139143 screw_ie8 : true
140144 }
141145 } ) ,
142- new ExtractTextPlugin ( '[name].[contenthash:8].css' )
146+ new ExtractTextPlugin ( 'static/css/ [name].[contenthash:8].css' )
143147 ]
144148} ;
Original file line number Diff line number Diff line change @@ -40,16 +40,28 @@ webpack(config).run(function(err, stats) {
4040 . filter ( asset => / \. ( j s | c s s ) $ / . test ( asset . name ) )
4141 . map ( asset => {
4242 var fileContents = fs . readFileSync ( paths . appBuild + '/' + asset . name ) ;
43+ var size = gzipSize ( fileContents ) ;
4344 return {
44- name : asset . name ,
45- size : gzipSize ( fileContents )
45+ folder : path . join ( 'build' , path . dirname ( asset . name ) ) ,
46+ name : path . basename ( asset . name ) ,
47+ size : size ,
48+ sizeLabel : filesize ( size )
4649 } ;
4750 } ) ;
4851 assets . sort ( ( a , b ) => b . size - a . size ) ;
52+
53+ var longestSizeLabelLength = Math . max . apply ( null ,
54+ assets . map ( a => a . sizeLabel . length )
55+ ) ;
4956 assets . forEach ( asset => {
57+ var sizeLabel = asset . sizeLabel ;
58+ if ( sizeLabel . length < longestSizeLabelLength ) {
59+ var rightPadding = ' ' . repeat ( longestSizeLabelLength - sizeLabel . length ) ;
60+ sizeLabel += rightPadding ;
61+ }
5062 console . log (
51- ' ' + chalk . dim ( 'build' + path . sep ) + chalk . cyan ( asset . name ) + ': ' +
52- chalk . green ( filesize ( asset . size ) )
63+ ' ' + chalk . green ( sizeLabel ) +
64+ ' ' + chalk . dim ( asset . folder + path . sep ) + chalk . cyan ( asset . name )
5365 ) ;
5466 } ) ;
5567 console . log ( ) ;
Original file line number Diff line number Diff line change @@ -61,7 +61,9 @@ npm run build
6161
6262# Check for expected output
6363test -e build/* .html
64- test -e build/* .js
64+ test -e build/static/js/* .js
65+ test -e build/static/css/* .css
66+ test -e build/static/media/* .svg
6567
6668# Pack CLI
6769cd global-cli
@@ -84,7 +86,9 @@ npm run build
8486
8587# Check for expected output
8688test -e build/* .html
87- test -e build/* .js
89+ test -e build/static/js/* .js
90+ test -e build/static/css/* .css
91+ test -e build/static/media/* .svg
8892
8993# Test the server
9094npm start -- --smoke-test
@@ -95,7 +99,9 @@ npm run build
9599
96100# Check for expected output
97101test -e build/* .html
98- test -e build/* .js
102+ test -e build/static/js/* .js
103+ test -e build/static/css/* .css
104+ test -e build/static/media/* .svg
99105
100106# Test the server
101107npm start -- --smoke-test
You can’t perform that action at this time.
0 commit comments