ekjcfn3902039
ekjcfn3902039

Reputation: 1839

Using module in vue.config.js

I am trying to use the following code in my vue.config.js file, but it is giving me errors that module is not allowed. I am aware that there are configureWebpack and chainWebpack options, but I have no idea how to convert the following to use them. Any help would be appreciated

var path = require('path');
module.exports = {
  foo:{},
  bar{},

  // Putting module in here does not work    
  module: { 
        rules: [ 
            { 
                test: /\.vue$/, 
                loader: 'vue-loader', 
                options: { 
                    loaders: { 
                        'scss': [ 
                            'vue-style-loader', 
                            'css-loader', 
                            { 
                                loader: "sass-loader", 
                                options: { 
                                    includePaths: [ 
                                        path.resolve(__dirname, "./node_modules/@syncfusion") 
                                    ] 
                                } 
                            } 
                        ] 
                    } 
                } 
            } 
        ] 
  } 
}

and in my vue file

<style lang="scss">
@import 'subfolder-inside-syncfusion/some-file.scss';
</style>

Link to code I found:

https://www.syncfusion.com/forums/139116/scss-files-when-included-in-my-file-doesnt-work-as-expected

Upvotes: 1

Views: 2990

Answers (1)

r0skar
r0skar

Reputation: 8706

You dont have to tap into the webpack config, if all you need is to include a global SCSS file. To import @syncfusion from node_modules, you can setup your vue.config.js like so:

css: {
  loaderOptions: {
    sass: {
      data: `@import "~@syncfusion";`
    }
  }
}

For more info, see the Vue docs "Working with CSS".

Upvotes: 1

Related Questions