mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
parent
15f9994928
commit
2ff8b5aaf6
@ -1,15 +1,40 @@
|
|||||||
import ExtractTextPlugin from 'extract-text-webpack-plugin'
|
import ExtractTextPlugin from 'extract-text-webpack-plugin'
|
||||||
|
import { join } from 'path'
|
||||||
|
|
||||||
export function extractStyles () {
|
export function extractStyles () {
|
||||||
return !this.options.dev && this.options.build.extractCSS
|
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)) {
|
if (extractStyles.call(this)) {
|
||||||
return ExtractTextPlugin.extract({
|
return ExtractTextPlugin.extract({
|
||||||
use: ['css-loader?minify&sourceMap'].concat(loader),
|
use: [cssLoader].concat(loaders),
|
||||||
fallback: 'vue-style-loader?sourceMap'
|
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