Skip to content

Example web app config

Tomasz Pluskiewicz edited this page Nov 19, 2019 · 3 revisions

Example configuration

Here are some examples of setting up web frameworks to use @zazuko/rdf-vocabularies package

vue.js

const webpack = require('webpack')

module.exports = {
  chainWebpack: config => {
    config.module
      .rule('nq')
      .test(/\.nq$/)
      .use('raw-loader')
      .loader('raw-loader')
      .end()

    config.plugin('prefetch').tap(options => {
      options[0].fileBlacklist = options[0].fileBlacklist || []
      options[0].fileBlacklist.push(/vocab-\w+\.js$/)
      return options
    })
  },
  configureWebpack: {
    plugins: [
      new webpack.NamedChunksPlugin((chunk) => {
        const vocabModule = [...chunk._modules].find(m => /rdf-vocabularies\/ontologies$/.test(m.context))

        if (vocabModule) {
          const matchVocabName = vocabModule.id.match(/(\w+)\.nq$/)
          if (matchVocabName) {
            return 'vocab-' + matchVocabName[1]
          }
        }

        return chunk.name
      })
    ]
  }
}
Clone this wiki locally