11'use strict'
22const path = require ( 'path' )
33const config = require ( '../config' )
4- const ExtractTextPlugin = require ( 'extract-text-webpack -plugin' )
4+ const MiniCssExtractPlugin = require ( 'mini-css-extract -plugin' )
55const packageConfig = require ( '../package.json' )
66
7- exports . assetsPath = function ( _path ) {
8- const assetsSubDirectory = process . env . NODE_ENV === 'production'
9- ? config . build . assetsSubDirectory
10- : config . dev . assetsSubDirectory
7+ exports . assetsPath = function ( _path ) {
8+ const assetsSubDirectory =
9+ process . env . NODE_ENV === 'production'
10+ ? config . build . assetsSubDirectory
11+ : config . dev . assetsSubDirectory
1112
1213 return path . posix . join ( assetsSubDirectory , _path )
1314}
1415
15- exports . cssLoaders = function ( options ) {
16+ exports . cssLoaders = function ( options ) {
1617 options = options || { }
1718
1819 const cssLoader = {
@@ -30,8 +31,22 @@ exports.cssLoaders = function (options) {
3031 }
3132
3233 // generate loader string to be used with extract text plugin
33- function generateLoaders ( loader , loaderOptions ) {
34- const loaders = options . usePostCSS ? [ cssLoader , postcssLoader ] : [ cssLoader ]
34+ function generateLoaders ( loader , loaderOptions ) {
35+ const loaders = [ ]
36+
37+ // Extract CSS when that option is specified
38+ // (which is the case during production build)
39+ if ( options . extract ) {
40+ loaders . push ( MiniCssExtractPlugin . loader )
41+ } else {
42+ loaders . push ( 'vue-style-loader' )
43+ }
44+
45+ loaders . push ( cssLoader )
46+
47+ if ( options . usePostCSS ) {
48+ loaders . push ( postcssLoader )
49+ }
3550
3651 if ( loader ) {
3752 loaders . push ( {
@@ -42,32 +57,24 @@ exports.cssLoaders = function (options) {
4257 } )
4358 }
4459
45- // Extract CSS when that option is specified
46- // (which is the case during production build)
47- if ( options . extract ) {
48- return ExtractTextPlugin . extract ( {
49- use : loaders ,
50- fallback : 'vue-style-loader'
51- } )
52- } else {
53- return [ 'vue-style-loader' ] . concat ( loaders )
54- }
60+ return loaders
5561 }
56-
5762 // https://vue-loader.vuejs.org/en/configurations/extract-css.html
5863 return {
5964 css : generateLoaders ( ) ,
6065 postcss : generateLoaders ( ) ,
6166 less : generateLoaders ( 'less' ) ,
62- sass : generateLoaders ( 'sass' , { indentedSyntax : true } ) ,
67+ sass : generateLoaders ( 'sass' , {
68+ indentedSyntax : true
69+ } ) ,
6370 scss : generateLoaders ( 'sass' ) ,
6471 stylus : generateLoaders ( 'stylus' ) ,
6572 styl : generateLoaders ( 'stylus' )
6673 }
6774}
6875
6976// Generate loaders for standalone style files (outside of .vue)
70- exports . styleLoaders = function ( options ) {
77+ exports . styleLoaders = function ( options ) {
7178 const output = [ ]
7279 const loaders = exports . cssLoaders ( options )
7380
0 commit comments