laravel blade templates minifier using laravel-mix # laravel 5.4 - minify

As of laravel 5.4, they are no longer using gulp but rather webpack, and they no longer use laravel-elixir but rather a new package they called laravel-mix, now I use a package called laravel-elixir-blade-minifier which minifies laravel-blade templates, how do I use it with now with laravel-mix? I mean, I'm getting confused here.

you can try: https://github.com/hiseanchang/laravel-mix-template-minifier
npm install --save-dev laravel-mix-template-minifier
// webpack.mix.js
let mix = require('laravel-mix');
mix.minTemplate = require('laravel-mix-template-minifier')
if (mix.inProduction()) {
mix.minTemplate('storage/framework/views/*.php', 'storage/framework/views/')
}

Related

Run gulp via cake Start-Process

I'm building site via gulp inside a windows container:
mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-1909
The container have nodejs and gulp-cli installed in it as following (in Dockerfile):
#Install NodeJs
RUN (New-Object Net.WebClient).DownloadFile('https://nodejs.org/dist/v12.16.3/node-v12.16.3-win-x64.zip', 'node.zip'); \
Expand-Archive -LiteralPath 'node.zip' -DestinationPath '.' ; \
Start-Process -FilePath '.\node-v12.16.3-win-x64\npm' -NoNewWindow -Wait -ArgumentList 'install -g gulp-cli' ; \
$env:PATH = 'c:\tools\node-v12.16.3-win-x64;' + $env:PATH; \
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine);
As you can see I'm installing node in the container under c:\tools\node-v12.16.3-win-x64.
In my cake script i try to execute gulp file as following:
StartProcess("cmd", new ProcessSettings {
Arguments = "/c gulp",
WorkingDirectory = projectDir)
});
But seems that Start-Process cannot find the file... I'm getting this output from cake Start-Process:
Executing: "cmd" /c gulp
'gulp' is not recognized as an internal or external command
Running the container interactive I can see the file it is in that place and if I run gulp from projectDir all works.
I've also try it to run it like all of the following forms without success:
StartProcess("powershell", new ProcessSettings {
Arguments = "gulp",
WorkingDirectory = projectDir)
});
StartProcess("gulp");
StartProcess("gulp.cmd");
This is the output from within the container regarding npn, gulp versions (requested from comments):
EDIT:
That 'Local version: Unknown' seems off. Is C:\code your project directory?
When I look at the 'official' gulp configuration steps, the installation results in having both a CLI and local version.
(see: https://gulpjs.com/docs/en/getting-started/quick-start/ )
You could consider using Cake.Gulp which can help run gulp with cake either from a local or global installation:
Namespace: https://cakebuild.net/api/Cake.Gulp/
Example usage: https://cake-contrib.github.io/Cake.Gulp/docs/usage/examples
Perhaps making sure that npm installed gulp locally might do the trick because cake is expecting a local variant. I am unfortunately inexperienced with cake, so this is my best guess after doing some basic research.
(one of my sources: Why do we need to install gulp globally and locally? )
Original answer
You could try using an absolute path to the gulp application.
For example:
StartProcess("cmd", new ProcessSettings {
Arguments = "/c c:\tools\node-v12.16.3-win-x64\gulp",
WorkingDirectory = projectDir)
});
It could be that your environment is not set properly, I found this that could be of use: Appending to PATH in a Windows Docker container

i create project in angular 6 using angular cli tool but it gives error import * as fs from 'fs';

i create project in angular 6 using angular cli tool but it gives error when i import * as fs from 'fs'(integrate electron app). The error message Module not found: Error: Cannot resolve module 'fs'
I assume you're using node.
Are you using webpack? If so see
here
The solution is to add
node: {
fs: 'empty'
}
to your webpack config.
If that doesn't work, try changing your import statement to a require:
const fs = require('fs');, as the node documentation recommends.

Babel dependency not resolved in react app created using "create-react-app" utility

I have created a react-app using create-react-app utility but when I import a node module then it gives me error stating :
./node_modules/#nross/react-vega/src/VegaLite.js
Module parse failed: Unexpected token (17:2)
You may need an appropriate loader to handle this file type.
| onParseError,
| children,
| ...otherProps
| }) => {
| const adjustedSpec = { ...spec };
And when I import babel-loader into the file where I am importing the node module then it is giving me the error:-
Failed to compile.
./node_modules/babel-core/lib/helpers/resolve.js
Module not found: Can't resolve 'module' in 'C:\VegaDemo\my-app\node_modules\babel-core\lib\helpers'.
You need to eject in order to customize the boilerplate.
Simply run
npm run eject
Or
yarn run eject
If you use yarn.
Then, install your npm module and run
npm run install
Without eject, the boilerplate is locked up.

polymer-cli build fails for element starter template

I am trying to create a reusable component using polymer cli.
I would like to use this component into another project where i can include it as a single file import.
But when I am trying to build the project, it keeps failing.
Below are details of my environment.
$node --version
v4.6.0
$ npm --version
2.15.9
$ polymer --version
0.16.0
$ polymer init
? Which starter template would you like to use? element
info: Running template element...
? Element name (my-el)
$polymer build
$ polymer build
info: Building application...
info: Generating build/unbundled...
info: Generating build/bundled...
error: Uncaught exception: Error: file path is not in root: /Users/yogeshkulkarni/workspace/polymer/polymer/polymer.html (/Users/yogeshkulkarni/workspace/polymer/my-el)
error: Error: file path is not in root: /Users/yogeshkulkarni/workspace/polymer/polymer/polymer.html (/Users/yogeshkulkarni/workspace/polymer/my-el)
at Object.urlFromPath (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/path-transformers.js:41:15)
at StreamAnalyzer.getFile (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:107:39)
at StreamResolver.accept (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/lib/analyzer.js:210:34)
at FileLoader.request (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/lib/loader/file-loader.js:64:27)
at Analyzer.load (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/lib/analyzer.js:121:32)
at Analyzer._getDependencies (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/lib/analyzer.js:433:25)
at Analyzer._dependenciesLoadedFor (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/lib/analyzer.js:401:25)
at Analyzer._parseHTML (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/lib/analyzer.js:227:50)
at null._onTimeout (/usr/local/lib/node_modules/polymer-cli/node_modules/polymer-build/node_modules/hydrolysis/lib/analyzer.js:125:39)
at Timer.listOnTimeout (timers.js:92:15)
polymer-cli build works fine when I choose application starter template. Is polymer-cli doesn't support building element starter template?
I had similar problems. I used the polymer INIT - 'a blank application template', to create my project.
Which didn't provide a polymer.json configuration file. I added and configured this file. Now polymer BUILD is without any errors (in my project). Because polymer BUILD needs to know about your project structure. See https://www.polymer-project.org/1.0/toolbox/server
The docs for polymer-cli state:
This command is for app projects only.
And it currently doesn't provide a user-friendly error message for this scenario, so you'll see it crash with a stack trace when building element projects.

How to setup google-closure-compiler to recognize NodeJs core modules

I am trying to setup my google-closure-compiler to be able to read my files which uses Node core modules and I read online that I need the NodeJS externs... I downloaded a set of externs from: https://github.com/dcodeIO/node.js-closure-compiler-externs (which is like 2 years old??) and then in the compiler option I added the following in my gulpfile.js:
process_common_js_modules: true,
externs: '../node.js-closure-compiler-externs/fs.js',
When running gulp I get:
[19:38:07] gulp-google-closure-compiler: /src/js/myfile.js:3: ERROR - Failed to load module "fs"
const fs = require('fs');
What is really the right way to setup a JavaScript project that uses Node.js and have google-closure-compiler regconize things properly? Is there a step by step tutorial somewhere?