I used the component groups and directives as Vue plugins in nuxtjs. I also use Carousel in bootstrap and 2 plugins of Vue were VueCarousel and Vue-Carousel 3D
After build in production => PurecssPlugin remove a lot of unused Css => It's good! But it breaks the pages, I have two problem:
- Some components don't receive bootstrap, like col-md-4 ...
- Carousel of bootstrap and 2 plugins of Vue => It's totally ruin :(
Hope someone can help me <3 Many thanks!
This is my boostrap-vue plugin:
import Vue from 'vue'
import {
LayoutPlugin,
CardPlugin,
ButtonPlugin,
PaginationNavPlugin,
} from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
Vue.use(LayoutPlugin, { breakpoints: ['cols', 'sm', 'md', 'lg', 'xl'] })
Vue.use(CardPlugin)
Vue.use(ButtonPlugin)
Vue.use(PaginationNavPlugin)
This is my nuxt config:
const path = require('path')
const PurgecssPlugin = require('purgecss-webpack-plugin')
const glob = require('glob-all')
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
.......
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{
rel: 'stylesheet',
href: 'https://use.fontawesome.com/releases/v5.4.2/css/all.css',
integrity: 'sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns',
crossorigin: 'anonymous',
},
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css?family=Varela+Round',
},
],
script: [
{
src: 'https://code.jquery.com/jquery-3.3.1.slim.min.js',
integrity: 'sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E=',
crossorigin: 'anonymous',
},
{
src: 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js',
integrity: 'sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy',
crossorigin: 'anonymous',
},
],
},
...
/*
** Plugins to load before mounting the App
*/
plugins: [
{
src: '~/plugins/vue-lazy-load',
ssr: false,
},
'~/plugins/boostrap-vue',
],
...
/*
** Nuxt.js modules
*/
modules: ['@nuxtjs/axios', '@nuxtjs/pwa'],
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
...
build: {
// analyze: {
// analyzerMode: 'static',
// },
filenames: {
chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[chunkhash].js'),
img: ({ isDev }) => (isDev ? '[path][name].[ext]' : 'img/[hash:7].[ext]'),
},
extractCSS: true,
optimization: {
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',
test: /\.(css|vue)$/,
chunks: 'all',
enforce: true,
},
},
},
},
extend(config, { isDev, isClient, loaders: { vue } }) {
if (isDev || isClient) {
config.plugins.push(
new PurgecssPlugin({
// content: [],
// css: [],
fontFace: true,
rejected: true,
paths: glob.sync([
path.join(__dirname, './pages/**/*.vue'),
path.join(__dirname, './layouts/**/*.vue'),
path.join(__dirname, './components/**/*.vue'),
]),
whitelist: ['html', 'body'],
}),
)
}
},
},
}