import path , { join } from 'path' ; import { Configuration } from '@nuxt/types' ; import Sass from 'sass' ; import Purgecss from '@fullhuman/postcss-purgecss' ; import _ from 'lodash' ; import pkg from './package.json' ; import { nav } from './config' ; const purgecss = Purgecss ( { content : [ './pages/**/*.html' , './pages/**/*.vue' , './components/**/*.vue' , './components/**/*.jsx' , ] , defaultExtractor : ( content ) => content . match ( /[A-Za-z0-9-_:/]+/g ) || [ ] , whitelist : [ 'html' , 'body' , 'nuxt-progress' ] , whitelistPatternsChildren : [ /^token/ , /^pre/ , /^code/ , /^line-numbers-wrapper/ , /^line-number/ ] , } ) ; const tailwindJS = join ( __dirname , 'tailwind.config.js' ) ; const generatePaths = function ( navs ) { const res = _ . flatMap ( navs , item => { return item . groups ; } ) ; let temp = _ . flatMap ( res , item => { return item . list ; } ) ; temp = temp . map ( item => { return item . path ; } ) ; return temp ; } ; const config = { mode : 'universal' , head : { title : pkg . name , meta : [ { charset : 'utf-8' } , { name : 'viewport' , content : 'width=device-width, initial-scale=1' } , { hid : 'keywords' , name : 'keywords' , content : 'we-vue,wevue,weui,vue,vue组件,微信组件' , } , { hid : 'description' , name : 'description' , content : 'we-vue 是一套简洁高效的 vue 组件库，封装了 weui.css，其一系列组件适合微信等移动端 web 应用开发。' , } , ] , link : [ { rel : 'icon' , type : 'image/x-icon' , href : '/favicon.ico' } ] , } , loading : { color : '#fff' } , css : [ '~/assets/css/tailwind.css' , '~assets/css/main.scss' ] , plugins : [ ] , modules : [ '@nuxtjs/axios' , ] , buildModules : [ '@nuxt/typescript-build' ] , modulelsDir : [ '../../node_modules' ] , axios : { } , build : { quiet : false , parallel : false , extractCSS : process . env . NODE_ENV === 'production' , postcss : { plugins : [ require ( 'tailwindcss' ) ( tailwindJS ) , require ( 'autoprefixer' ) , ... ( process . env . NODE_ENV === 'production' ? [ purgecss ] : [ ] ) , ] , } , loaders : { scss : { implementation : Sass , } , } , extend ( config , ctx ) { config . module ! . rules . push ( { test : /\.md$/ , include : [ path . resolve ( __dirname , 'markdown' ) , path . resolve ( __dirname , '../../' ) , ] , exclude : /node_modules/ , use : [ { loader : '@tianyong90/vue-markdown-loader' , options : { mode : 'raw' , contentCssClass : 'markdown-body' , markdown : { lineNumbers : true , } , } , } , ] , } ) ; } , } , typescript : { typeCheck : true , ignoreNotFoundWarnings : true , } , generate : { routes : [ '404' ] . concat ( generatePaths ( nav . v2 ) , generatePaths ( nav . v3 ) ) , } , } ; export default config ;