mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-24 06:35:10 +00:00
41 lines
991 B
JavaScript
Executable File
41 lines
991 B
JavaScript
Executable File
import ExtractTextPlugin from 'extract-text-webpack-plugin'
|
|
import { join } from 'path'
|
|
|
|
export function extractStyles () {
|
|
return !this.options.dev && this.options.build.extractCSS
|
|
}
|
|
|
|
export function styleLoader (ext, loaders = []) {
|
|
// https://github.com/webpack-contrib/css-loader
|
|
const cssLoader = {
|
|
loader: 'css-loader',
|
|
options: {
|
|
minimize: true,
|
|
sourceMap: true,
|
|
// https://github.com/webpack/loader-utils#root-relative-urls
|
|
root: '~',
|
|
alias: {
|
|
'/static': join(this.options.srcDir, 'static'),
|
|
'/assets': join(this.options.srcDir, 'assets')
|
|
}
|
|
}
|
|
}
|
|
|
|
// https://github.com/vuejs/vue-style-loader
|
|
const vueStyleLoader = {
|
|
loader: 'vue-style-loader',
|
|
options: {
|
|
sourceMap: true
|
|
}
|
|
}
|
|
|
|
if (extractStyles.call(this)) {
|
|
return ExtractTextPlugin.extract({
|
|
use: [cssLoader].concat(loaders),
|
|
fallback: vueStyleLoader
|
|
})
|
|
}
|
|
|
|
return [vueStyleLoader, cssLoader].concat(loaders)
|
|
}
|