1111
1212const webpack = require ( 'webpack' ) ;
1313const ExtractTextPlugin = require ( 'extract-text-webpack-plugin' ) ;
14+ const extractText = require ( './loaders/extract-text' ) ;
1415const ManifestPlugin = require ( './webpack/webpack-manifest-plugin' ) ;
1516const DeleteUnusedEntriesJSPlugin = require ( './webpack/delete-unused-entries-js-plugin' ) ;
1617const AssetOutputDisplayPlugin = require ( './friendly-errors/asset-output-display-plugin' ) ;
@@ -26,6 +27,7 @@ const cssLoaderUtil = require('./loaders/css');
2627const sassLoaderUtil = require ( './loaders/sass' ) ;
2728const lessLoaderUtil = require ( './loaders/less' ) ;
2829const babelLoaderUtil = require ( './loaders/babel' ) ;
30+ const vueLoaderUtil = require ( './loaders/vue' ) ;
2931
3032class ConfigGenerator {
3133 /**
@@ -68,7 +70,10 @@ class ConfigGenerator {
6870 config . stats = this . buildStatsConfig ( ) ;
6971
7072 config . resolve = {
71- extensions : [ '.js' , '.jsx' ]
73+ extensions : [ '.js' , '.jsx' , '.vue' ] ,
74+ alias : {
75+ 'vue$' : 'vue/dist/vue.esm.js' ,
76+ }
7277 } ;
7378
7479 return config ;
@@ -111,10 +116,7 @@ class ConfigGenerator {
111116 } ,
112117 {
113118 test : / \. c s s $ / ,
114- use : ExtractTextPlugin . extract ( {
115- fallback : 'style-loader' + this . getSourceMapOption ( ) ,
116- use : cssLoaderUtil . getLoaders ( this . webpackConfig )
117- } )
119+ use : extractText . extract ( this . webpackConfig , cssLoaderUtil . getLoaders ( this . webpackConfig , false ) )
118120 } ,
119121 {
120122 test : / \. ( p n g | j p g | j p e g | g i f | i c o | s v g ) $ / ,
@@ -137,30 +139,21 @@ class ConfigGenerator {
137139 if ( this . webpackConfig . useSassLoader ) {
138140 rules . push ( {
139141 test : / \. s [ a c ] s s $ / ,
140- use : ExtractTextPlugin . extract ( {
141- fallback : 'style-loader' + this . getSourceMapOption ( ) ,
142- use : sassLoaderUtil . getLoaders ( this . webpackConfig )
143- } )
142+ use : extractText . extract ( this . webpackConfig , sassLoaderUtil . getLoaders ( this . webpackConfig ) )
144143 } ) ;
145144 }
146145
147146 if ( this . webpackConfig . useLessLoader ) {
148147 rules . push ( {
149148 test : / \. l e s s / ,
150- use : ExtractTextPlugin . extract ( {
151- fallback : 'style-loader' + this . getSourceMapOption ( ) ,
152- use : lessLoaderUtil . getLoaders ( this . webpackConfig )
153- } )
149+ use : extractText . extract ( this . webpackConfig , lessLoaderUtil . getLoaders ( this . webpackConfig ) )
154150 } ) ;
155151 }
156152
157153 if ( this . webpackConfig . useVueLoader ) {
158- loaderFeatures . ensureLoaderPackagesExist ( 'vue' ) ;
159-
160154 rules . push ( {
161- test : / \. v u e / ,
162- loader : 'vue-loader' ,
163- options : this . webpackConfig . vueOptions
155+ test : / \. v u e $ / ,
156+ use : vueLoaderUtil . getLoaders ( this . webpackConfig , this . webpackConfig . vueLoaderOptions )
164157 } ) ;
165158 }
166159
@@ -387,10 +380,6 @@ class ConfigGenerator {
387380 https : this . webpackConfig . useDevServerInHttps ( )
388381 } ;
389382 }
390-
391- getSourceMapOption ( ) {
392- return this . webpackConfig . useSourceMaps ? '?sourceMap' : '' ;
393- }
394383}
395384
396385/**
0 commit comments