test: build.styleResources for style-resources-loader

This commit is contained in:
Clark Du 2017-12-08 15:39:58 +08:00 committed by Pooya Parsa
parent a5e30b763a
commit 81bb278305
2 changed files with 19 additions and 1 deletions

View File

@ -48,6 +48,11 @@ module.exports = {
analyzerMode: 'disabled', analyzerMode: 'disabled',
generateStatsFile: true generateStatsFile: true
}, },
styleResources: {
patterns: [
'~/assets/pre-process.scss'
]
},
extend(config, options) { extend(config, options) {
return Object.assign({}, config, { return Object.assign({}, config, {
devtool: 'nosources-source-map' devtool: 'nosources-source-map'

View File

@ -7,6 +7,7 @@ const port = 4007
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
let nuxt = null let nuxt = null
let builder = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
@ -15,7 +16,8 @@ test.before('Init Nuxt.js', async t => {
config.rootDir = rootDir config.rootDir = rootDir
config.dev = false config.dev = false
nuxt = new Nuxt(config) nuxt = new Nuxt(config)
await new Builder(nuxt).build() builder = new Builder(nuxt)
await builder.build()
await nuxt.listen(port, 'localhost') await nuxt.listen(port, 'localhost')
}) })
@ -128,6 +130,17 @@ test('Check /test.txt should return 404', async t => {
t.is(err.response.statusCode, 404) t.is(err.response.statusCode, 404)
}) })
test('Check build.styleResources for style-resources-loader', async t => {
const loaders = builder.styleLoader('scss')
const loader = loaders.find(l => l.loader === 'style-resources-loader')
t.is(typeof loader, 'object')
t.deepEqual(loader.options, {
patterns: [
'~/assets/pre-process.scss'
]
})
})
// Close server and ask nuxt to stop listening to file changes // Close server and ask nuxt to stop listening to file changes
test.after('Closing server and nuxt.js', t => { test.after('Closing server and nuxt.js', t => {
nuxt.close() nuxt.close()