Referencing assets in dotnet application after webpack bundle - asp.net

The project I am working on uses vue and vuetify with dotnet core MVC. A directory is created to contain vue code but after compilation, the asset reference is not consistent. The bundle goes to the wwwroot folder and the bundled assets try to reference that folder but it cannot because of dotnet. I used vue.config.js for the bundle configuration. When the project is run the asset references https://localhost:5000/wwwroot/build/img/image1.png but the correct location is https://localhost:5000/build/img/image1.png
How do I make it reference the correct location?

set publicPath to 'wwwroot' in your vue config file
see detail

Related

Symfony4 : Where is the assets folder?

I am following a course about Symfony 4
According to the course I should have an assets folder, but I don't have one
image of my project
Install WebpackEncoreBundle. This will trigger Symfony Flex to create the assets folder for you.
composer require symfony/webpack-encore-bundle
See: https://symfony.com/doc/current/frontend/encore/installation.html

How to add Bootstrap to my Symfony 4.1 project?

I tried to find a similar case to mine but didn't succeed.
Here is the issue. I followed Symfony documentation to add Bootstrap to my project.
I indeed get a bootstrap folder in a new folder called "nodes_modules".
The thing is i can't find a global.scss file anywhere (as mentioned in the tutorial) then i don't know where to put the following command:
#import "~bootstrap/scss/bootstrap";
Do i have to create this file or does it exist somewhere in my Symfony project?
Thank you in advance.
Yes, global is your application scss file, it can be named different on you wish. You can refer this documentation in order to see how to configure it (it is app.scss in the example)
I understood what was wrong there! So if you are creating a Symfony 4.1 project on mac and you don't know where to import your bootstrap theme(s) since you don't have any assets folder here is the solution:
To have the assets folder you have to install the webpack "encore".
Please make sure you have node.js and yarn installed before that.
Then just run the following commands inside your root project directory:
composer require symfony/webpack-encore-pack
yarn install
You might have now an "assets" folder inside your project with an assets/css/app.css file and a assets/js/app.js file.
Thank you for your time ScayTrase.

How to split the generated assets in seperated folders with Symfony Webpack Encore

I managed configure Webpack to output CSS and JS into respective sub-directories, i.e. public/assets/css and public/assets/js. However, I don't know how to do the same with Symfony Webpack Encore.
The directory where assets are generated is defined in the webpack.config.js file with .setPublicPath('/build').
I am not sure but since webpack is supposed to help you "not to care about generated assets" what is your need to split js/css files in sub folder ?

Change default location of node_modules in new ASP.NET5 project structure?

I am planning to use npm to manage all my JavaScript dependencies and get rid of bower from my ASP.NET5 project. I need npm to create node_modules folder in wwwroot location rather than its default location. I tried using .npmrc but VS2015 don't recognize it. Is there a way configure this?

sbt plugins isn't picked up from submodules?

I'm trying to convert a single module project into two modules with a
root aggregate. Feels like a normal thing to do.
So, to simplify I have removed the second project that I added, but I
do something like:
cd myproject
mkdir core
mv * core
and then add a build.sbt in myproject like
lazy val root = project.in( file(".") ).aggregate(core)
lazy val core = project in file("core")
However, trying to build core I get:
[myproject]/core/build.sbt:22: error: not found: value lessSettings
seq(lessSettings:_*)
which is the settings for a plugin added in project/plugins.sbt of the
original project now in
[myproject]/core/project/plugins.sbt
How come this is not picked up? Can't I have plugins living only in
submodules? cd:ing into core submodule and running sbt it works just fine. Do I have
to move my plugins to root/project? Pretty please, it can't be so?
Your plugin.sbt file is ignored because you cannot have a project subfolder in a sub-project of a multi-project build.
In a multi-project build,
The .sbt files of the root project, and all .sbt files of all sub-projects, are all part of a single build definition. The settings defined in a sub-project are just automatically scoped to that project.
Since there is only one build definition, there is only one project to build that build definition, and that is in the project/ folder of the root project. All project/ folders of sub-projects will be ignored.
In your case, moving your plugin.sbt to the build root project folder should make your plugin appear again.
Furthermore, if you only work on the core project, instead of running sbt in core, you can run sbt in the root project and type project core to "move" (actually, scope everything you do) to the core sub-project.

Resources