Skip to content

style in Vue Js single component are ignored #350

Closed
@alexis-regnaud

Description

@alexis-regnaud

Hi,

I add .enableVueLoader() in my webpack.config.js
I try to apply a style in my single vue component App.vue

But it's ingored and I do'nt know why... maybe a bug of vue-loader ?

My App.vue :

<template>
    <div id="app-vue">
        <div class="main">
            <h1>Main</h1>
            <div class="grid-container">
                <div class="grid-x grid-padding-x">
                    <div class="cell small-4">Cell 1</div>
                    <div class="cell small-4">Cell 2</div>
                    <div class="cell small-4">Cell 3</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "app",
        data() {
            return { };
        },
        components: {
        },
    }
</script>

<style  scoped>
    .cell{
        background-color: #0000F0;
    }
</style>

and my webpack.config.js :

// webpack.config.js
var Encore = require('@symfony/webpack-encore');

var path = require('path');

console.log( path.resolve(__dirname, './web'));

Encore
// the project directory where all compiled assets will be stored
    .setOutputPath('web/build/')

    // the public path used by the web server to access the previous directory
    .setPublicPath('/build')


    /** Add entry **/

    // will create public/build/app.js and public/build/app.css
    .addEntry('app', './web/assets/js/app.js')
    .addEntry('entrypoint', './app/Resources/views/front/entrypoint.js')
    .addEntry('unityload', './web/assets/unity_map/Build/UnityLoader.js')

    //Style
    .addStyleEntry('app_style',[
        './web/assets/scss/app.scss'
    ])

     /***************/


    // allow legacy applications to use $/jQuery as a global variable
    .autoProvidejQuery()

    // enable source maps during development
    .enableSourceMaps(!Encore.isProduction())

    // empty the outputPath dir before each build
    .cleanupOutputBeforeBuild()

    // show OS notifications when builds finish/fail
    .enableBuildNotifications()

    // create hashed filenames (e.g. app.abc123.css)
    .enableVersioning(Encore.isProduction())

    // allow sass/scss files to be processed
    .enableSassLoader(function(sassOptions) {}, {
        resolveUrlLoader: false
    })

    // to enable vue
    .enableVueLoader()

    .enablePostCssLoader((options) => {
          options.config = {
                  path: './postcss.config.js'
          };
     })
;


let config = Encore.getWebpackConfig();
config.resolve.alias = {
    'assets': path.resolve(__dirname, './web/assets')
};


// export the final configuration
module.exports = config;
//module.exports = Encore.getWebpackConfig();


Thank you in advance !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions