mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
Add extractCSS option
This commit is contained in:
parent
05085cbc99
commit
e148e4b93a
@ -3,7 +3,10 @@ const { join } = require('path')
|
||||
module.exports = {
|
||||
css: [
|
||||
'hover.css/css/hover-min.css',
|
||||
{ src: 'bulma', lang: 'sass' },
|
||||
'bulma/bulma.sass',
|
||||
join(__dirname, 'css/main.css')
|
||||
]
|
||||
],
|
||||
build: {
|
||||
extractCSS: true
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ debug.color = 2
|
||||
|
||||
const defaults = {
|
||||
analyze: false,
|
||||
extractCSS: false,
|
||||
publicPath: '/_nuxt/',
|
||||
filenames: {
|
||||
css: 'common.[chunkhash].css',
|
||||
|
@ -1,15 +1,15 @@
|
||||
import ExtractTextPlugin from 'extract-text-webpack-plugin'
|
||||
|
||||
export function extractStyles (ext) {
|
||||
return !this.dev && !!this.options.build.extractCSS && this.options.build.extractCSS[ext] !== false
|
||||
export function extractStyles () {
|
||||
return !this.dev && this.options.build.extractCSS
|
||||
}
|
||||
|
||||
export function styleLoader (ext, loader = []) {
|
||||
if (!extractStyles.call(this, ext)) {
|
||||
return ['vue-style-loader', 'css-loader'].concat(loader)
|
||||
}
|
||||
if (extractStyles.call(this)) {
|
||||
return ExtractTextPlugin.extract({
|
||||
use: ['css-loader?minimize'].concat(loader),
|
||||
fallback: 'vue-style-loader'
|
||||
})
|
||||
}
|
||||
return ['vue-style-loader', 'css-loader'].concat(loader)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ export default function ({ isClient }) {
|
||||
'styl': styleLoader.call(this, 'stylus', 'stylus-loader')
|
||||
},
|
||||
preserveWhitespace: false,
|
||||
extractCSS: extractStyles.call(this, 'vue')
|
||||
extractCSS: extractStyles.call(this)
|
||||
}
|
||||
// Return the config
|
||||
return config
|
||||
|
@ -18,7 +18,9 @@ test.before('Init Nuxt.js', async t => {
|
||||
config.rootDir = rootDir
|
||||
config.dev = false
|
||||
nuxt = new Nuxt(config)
|
||||
await nuxt.generate()
|
||||
try {
|
||||
await nuxt.generate() // throw an error (of /validate route)
|
||||
} catch (err) {}
|
||||
const serve = serveStatic(resolve(__dirname, 'fixtures/basic/dist'))
|
||||
server = http.createServer((req, res) => {
|
||||
serve(req, res, finalhandler(req, res))
|
||||
|
Loading…
Reference in New Issue
Block a user