Nuxt/lib/webpack/vue-loader.config.js
Pooya Parsa 87172100c7 [vue-loader] allow using builtin extractCSS functionality
This option is disabled by default and won't affect exiting users.
However users can easily enable this option using `nuxt.build.extractCSS`

Implementation is according to:
- https://github.com/vuejs/vue-loader/tree/master/docs/en/configurations
- https://ssr.vuejs.org/en/css.html
- https://github.com/vuejs/vue-hackernews-2.0/tree/master/build
2017-04-30 16:28:25 +04:30

31 lines
999 B
JavaScript

'use strict'
import { defaults } from 'lodash'
import { extractStyles, styleLoader } from './helpers'
export default function ({ isClient }) {
let babelOptions = JSON.stringify(defaults(this.options.build.babel, {
presets: ['vue-app'],
babelrc: false,
cacheDirectory: !!this.dev
}))
// https://github.com/vuejs/vue-loader/blob/master/docs/en/configurations
let config = {
postcss: this.options.build.postcss,
loaders: {
'js': 'babel-loader?' + babelOptions,
'css': styleLoader.call(this, 'css'),
'less': styleLoader.call(this, 'less', 'less-loader'),
'sass': styleLoader.call(this, 'sass', 'sass-loader?indentedSyntax'),
'scss': styleLoader.call(this, 'sass', 'scss-loader'),
'stylus': styleLoader.call(this, 'stylus', 'stylus-loader'),
'styl': styleLoader.call(this, 'stylus', 'stylus-loader')
},
preserveWhitespace: false,
extractCSS: extractStyles.call(this, 'vue')
}
// Return the config
return config
}