mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-24 09:28:41 +00:00
parent
15f9994928
commit
2ff8b5aaf6
@ -1,15 +1,40 @@
|
||||
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, loader = []) {
|
||||
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: ['css-loader?minify&sourceMap'].concat(loader),
|
||||
fallback: 'vue-style-loader?sourceMap'
|
||||
use: [cssLoader].concat(loaders),
|
||||
fallback: vueStyleLoader
|
||||
})
|
||||
}
|
||||
return ['vue-style-loader?sourceMap', 'css-loader?sourceMap'].concat(loader)
|
||||
|
||||
return [vueStyleLoader, cssLoader].concat(loaders)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user