V
V
veydlin2016-08-20 15:25:00
Less
veydlin, 2016-08-20 15:25:00

How to add a web project to VS?

I have a self-written system project in PHP, it uses TypeScript and Less, they need to be compiled
For Less, I installed Web Compiler
I create a new TypeScript project, but I can’t add the entire PHP project there, only the root directory files are added, what should I do?
And if there are other solutions to the problem, then I will be glad to listen (except for changing the IDE)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Nemiro, 2016-08-20
@veydlin

only root directory files are added

I didn't quite understand what it was about. Perhaps in Visual Studio 2015 , if you paste from explorer, files may not be included in the solution, only directories will be added. They will have to be turned on manually. To do this, you need to enable showing all files:
And then select the missing files and folders and include them in the project through the context menu:
In Visual Studio for PHP , I use PHP Tools for VS .
The PHP project did not want to be friends with TypeScript within Visual Studio . The easiest solution is to make a separate project for TypeScript (within one solution). AT
bundleconfig.json ( BundlerMinifier ) you can write the output of the collected files to any folder, including the folder with the PHP project .
Here you can see an example of how it can be.
Solution structure:
/РСшСниС
-- FrontEndScripts - ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ TypeScript
-- SmallServerAdmin - ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ PHP, Π² ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ, ΠΏΠΎΠΌΠΈΠΌΠΎ ΠΏΡ€ΠΎΡ‡Π΅Π³ΠΎ, ΡΠΎΠ±ΠΈΡ€Π°Ρ‚ΡŒΡΡ клиСнтский ΠΊΠΎΠ΄

[
  {
    "includeInProject": false,
    // Π²Ρ‹Π²ΠΎΠ΄ js Π΄Π΅Π»Π°Π΅ΠΌ Π² ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ SmallServerAdmin
    "outputFileName": "../SmallServerAdmin/Content/compiled.js",
    "inputFiles": [
      // Ρ„Π°ΠΉΠ»Ρ‹, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ Π΄ΠΎΠ»ΠΆΠ½Ρ‹ Π²Ρ…ΠΎΠ΄ΠΈΡ‚ΡŒ ΠΈΡ‚ΠΎΠ³ΠΎΠ²ΡƒΡŽ Π² сборку
      "libs/jquery-1.11.2.js",
      "libs/jquery-ui.min.js",
      "libs/jquery.json.min.js",
      "libs/jquery.caret.min.js"
      // ...
    ]
  }
]

TypeScript compiles to JavaScript in the same place as the TypeScript . Each file is written in bundleconfig.json . Then all this is collected in the final file /SmallServerAdmin/Content/compiled.js .
Bad, but simple solution.
You can also try in the TypeScript project settings (Project -> Project Properties) to specify the build options and the output folder (the path can be relative).
If you stay within the same project, then you can try to make a TypeScript configuration file in the root of the project: tsconfig.json . Perhaps it will be used, but in projects other than TypeScriptI haven't tested this and can't say for sure how it will work.
{
  "compilerOptions": {
    "outDir": "./ΠΊΡƒΠ΄Π° Π΄Π΅Π»Π°Ρ‚ΡŒ Π²Ρ‹Π²ΠΎΠ΄ ΠΊΠΎΠΌΠΏΠΈΠ»ΠΈΡ€ΠΎΠ²Π°Π½Π½Ρ‹Ρ… Ρ„Π°ΠΉΠ»ΠΎΠ²",
    "sourceMap": false,
    "noImplicitAny": true,
    "module": "CommonJS",
    "target": "es5"
  },
  "files": [
    // Ρ„Π°ΠΉΠ»Ρ‹ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚Π°
    "./init.ts"
  ]
}

More can be done with WebPack , but it will be much more difficult. An example solution ( TypeScript + PHP ) can be found here .
For Webpack you will need:
You can leave TypeScript build management to the studio, it's the easiest thing to do. And everything else is written in webpack.config.js . But everything can be very difficult, it can take a couple of dozen hours to get the optimal configuration :-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question