I've tried to follow all these other threads but am unable to get this to work for some reason:
Vendor CSS files not being compiled for Brunch
Separating app and vendor css in Brunch
For some reason, I'm unable to get brunch to ouput vendor CSS at all?
The particular package I'm talking about is Fancybox which has a css file source/jquery.fancybox.css.
I've overridden the fancybox main in my bower.json (as no main is included in the package). For some reason, no css is output, only the javascript. I feel like I must be doing something trivially wrong as no errors are output either and I even see the css file as being watched in the debug output?
Output of brunch b -Pd:
❯ brunch b -Pd > brunch-debug.txt
brunch:watch Loaded plugins: javascript-brunch, sass-brunch +0ms
brunch:watch File 'package.json' received event 'add' +5ms
brunch:watch File 'bower.json' received event 'add' +1ms
brunch:watch File 'brunch-config.coffee' received event 'add' +0ms
brunch:file-list Reading 'bower_components/fancybox/source/jquery.fancybox.js' +1ms
brunch:watch File 'bower_components/fancybox/source/jquery.fancybox.js' received event 'add' +0ms
brunch:file-list Reading 'bower_components/fancybox/source/jquery.fancybox.css' +0ms
brunch:watch File 'bower_components/fancybox/source/jquery.fancybox.css' received event 'add' +0ms
brunch:source-file Initializing fs_utils.SourceFile: {"path":"bower_components/fancybox/source/jquery.fancybox.js","isntModule":true,"isWrapped":true} +1ms
brunch:pipeline Compiling 'bower_components/fancybox/source/jquery.fancybox.js' with 'JavaScriptCompiler' +1ms
brunch:file-list Compiled file 'bower_components/fancybox/source/jquery.fancybox.js'... +40ms
brunch:write Writing 1/1 files +71ms
brunch:generate Concatenating bower_components/fancybox/source/jquery.fancybox.js to public/libraries.js +3ms
brunch:common Writing file 'public/libraries.js' +7ms
I've setup my config files so:
brunch-config.coffee
module.exports = config:
files:
javascripts: joinTo:
'libraries.js': /^(?!app\/)/
'app.js': /^app\//
stylesheets: joinTo:
'vendor.css': /^(bower_components|vendor)\//
'app.css': /^app\//
modules:
wrapper: false
definition: false
bower.json
{
"name": "brunch-test-fancybox",
"version": "0.0.0",
"authors": [
"Test <test#test.com>"
],
"description": "",
"main": "",
"moduleType": [],
"license": "MIT",
"homepage": "",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"overrides": {
"fancybox": {
"main": [
"source/jquery.fancybox.css",
"source/jquery.fancybox.js"
]
}
},
"dependencies": {
"fancybox": "~2.1.5"
}
}
package.json
{
"name": "brunch-test-fancybox",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"brunch": "^1.8.5",
"javascript-brunch": "^1.7.1",
"sass-brunch": "^1.9.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Add the css-brunch plugin to your project, otherwise Brunch does not know how you want to handle .css files.
Related
I was trying to get this setup to work for a while and there is no support or similar issues over the web. There is actually one closed topic on Local community but no solution at all.
So, my setup is:
Local by Flywheel server for WordPress
VS Code with Node installed
#wordpress/scripts to bundle all my CSS and JS files
browser-sync to live reload
Here is my .json file:
{
"name": "mywebsite",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"live": "npm-run-all --parallel sync start",
"sync": "browser-sync start -p 'mywebsite.local' --files '**/*.php' 'build/*.js' 'build/*.css'",
"build": "wp-scripts build",
"start": "wp-scripts start",
"dev": "wp-scripts start",
"devFast": "wp-scripts start",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#wordpress/scripts": "*",
"browser-sync": "^2.27.9",
"node-sass": "^7.0.1",
"normalize.css": "^8.0.1",
"npm-run-all": "^4.1.5"
}
}
So, the Browser Sync starts nicely in the command line, when starting it opens a new browser windows with this Error below.
There is nothing in the Local's log as they advice on this error screen.
Do anyone encounters similar problems and have the knowledge how to fix that?
I would be super grateful for any hints, walkarounds or solutions or maybe someone can share the other simple setup ideas to achieve the live reload functionality?
I had the same issue, it comes from the combination of npm-run-all and browser-sync. Instead of using npm-run-all, I used browser-sync as a webpack plugin.
Install browser-sync-webpack-plugin
npm install browser-sync-webpack-plugin -D
Then add browser-sync-webpack-plugin as plugin in your webpack.config.js file. As you use #wordpress/scripts, your config will be :
const defaultConfig = require( '#wordpress/scripts/config/webpack.config' );
const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
module.exports = {
...defaultConfig,
plugins: [
...defaultConfig.plugins,
new BrowserSyncPlugin({
// browse to http://localhost:3000/ during development,
// ./public directory is being served
host: 'localhost',
port: 3000,
proxy: 'http://YOURDOMAIN.local/'
})
]
};
Take care to replace YOURDOMAIN.
Now when you run :
npm start
browser-sync will be automatically launched.
Since I've posted this question in several software forms and got no useful answer, I hope to get an answer here from you as my colleges.
If you program in WordPress, you might now translations files .po/.mo. I'm looking now for a plugin in IntelliJ / WebStorm that can generate .mo files and extend the .po files above each translation by the used places:
#: /includes/.......
msgid "Cheatin’ huh?"
msgstr "So geht das leider nicht.."
So does anyone knows if there is a plugin that can do this? It would be enough to not enter the usage each time manually because this annoys me so much. The generation would only be a nice to have.
Thanks a lot!
As of writing this answer there is still no plugin that does this seemlessly. However you can acheive automation using a GRUNT task.
Using Grunt requires you have a nodejs development environment configured
Create a package.json in your project root similar to
{
"name": "yourProject",
"majorVersion": "0",
"minorVersion": "0",
"incrementalVersion": "1",
"qualifier": "-alpha",
"version": "0.0.1-alpha",
"description": "My great idea",
"main": "GruntFile.js",
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "https://yourgitrepo.com/name/project.git"
},
"dependencies": {},
"devDependencies": {
"grunt": "^1.5.3",
"grunt-cli": "^1.4.3",
"grunt-contrib-clean": "^2.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-exec": "^3.0.0",
"grunt-pot": "^0.3.0",
"grunt-replace": "^2.0.2",
"load-grunt-tasks": "^5.1.0",
"npm-cli": "^0.1.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Your Name",
"license": "SEE LICENCE IN LICENCE.txt"
}
Once created navigate using a terminal and run
npm install
This creates a node environment.
Now create a GruntFile.js
See below for example.
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
prvPkg: grunt.file.readJSON('private.json'),
clean: {
standard: ['myproject/target',
],
},
makepot: {
target: {
options: {
cwd: 'myproject/target/generated/myproject',
include: ['.*'],
domainPath: 'languages/', // Where to save the POT file.
mainFile: 'myproject.php', // Main project file.
potFilename: 'myproject.pot', // Name of the POT file.
type: 'wp-plugin',
potHeaders: {
'report-msgid-bugs-to': 'https://www.myproject.com.au',
'plural-forms': 'nplurals=2; plural=n != 1;',
'last-translator': 'Author Name <author#myproject.com.au>',
'language-team': 'My Team <author#myproject.com.au>',
poedit:true,
'x-poedit-keywordslist': true,
'x-textdomain-support': 'yes'
}
}
}
},
});
// Default task(s).
grunt.registerTask('createMachineLanguage', '', function () {
let exec = require('child_process').execSync;
let options = {
cwd: 'myproject/target/generated/myproject/languages/',
encoding: 'utf8'
}
let result = exec("msginit --no-translator --input=myproject.pot --locale=en --output=myproject_en_AU.po",options);
result += exec("msgfmt myproject_en_AU.po -o myproject_en_AU.mo",options);
result += exec("rm myproject_en_AU.po",options);
grunt.log.writeln(result);
});
grunt.registerTask('default',['clean:standard','makepot','createMachineLanguage'] );
}
The critical components are the grunt-pot grunt plugin. Your terminal environment must have the GNU gettext intalled which provides the function
msginit and msgfmt. The grunt process executes these tasks automatically.
Please note my environment was Ubuntu so you can see I use an rm to remove the po file once it is converted to an mo file.
So using the GruntTask plugin you can create your language files automatically. Executing them from GruntTask.
I have two projects in a parent folder:
parentFolder
| webApiFolder
| testsFolder
Using the terminal, I need to pass the --project parameter to dotnet run. As such, I figure it'd be easier to just create a task and run the task instead. However, I can't get the task to work.
Task:
{
"label": "run api",
"command": "dotnet",
"type": "process",
"args": [
"run",
"--project ${workspaceFolder}\\WebApi\\mercury-ms-auth.csproj"
],
"problemMatcher": "$msCompile"
}
Output:
> Executing task: C:\Program Files\dotnet\dotnet.exe run --project G:\Git_CS\mercury-ms-auth\WebApi\mercury-ms-auth.csproj <
Couldn't find a project to run. Ensure a project exists in g:\Git_CS\mercury-ms-auth, or pass the path to the project using --project.
The terminal process terminated with exit code: 1
However, if I run dotnet run --project G:\Git_CS\mercury-ms-auth\WebApi\mercury-ms-auth.csproj, that launches the project perfectly.
Similarly, my test and code coverage task works perfectly:
{
"label": "test with code coverage",
"command": "dotnet",
"type": "process",
"args": [
"test",
"${workspaceFolder}/Tests/Tests.csproj",
"/p:CollectCoverage=true",
"/p:CoverletOutputFormat=cobertura"
],
"problemMatcher": "$msCompile"
}
One solution is to "type": "shell" and pass through the whole command.
{
"label": "run api",
"command": "dotnet run --project ${workspaceFolder}\\WebApi",
"type": "shell",
"problemMatcher": "$msCompile"
}
I'm trying to program arduino in vscode. The problem is that It's giving me weird header errors:
cannot open source file "avr/pgmspace.h" (dependency of "C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\Arduino.h")
This is my arduino.json:
"board": "arduino:avr:uno"
}
This is my c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:\\Program Files (x86)\\Arduino\\tools\\**",
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**"
],
"forcedInclude": [
"C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino\\Arduino.h"
],
"intelliSenseMode": "msvc-x64",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
It should recursively include all of the required libraries, and even if imanually try to add the path to avr/pgmspace.h or its directory, it keeps giving me the same errors.
How do I solve this error?
Based on the responses to this issue, I added "c:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\avr\\**" to my include path in c_cpp_properties.json:
"includePath": [
"c:\\Program Files (x86)\\Arduino\\tools\\**",
"c:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\**",
"c:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr\\avr\\**"
],
For anyone who stumbles here on a Mac, here is the config that works for me with the Uno:
{
"env": {
"arduino_path": "/Applications/Arduino.app/Contents/Java",
"arduino_avr_include_path": "${env:arduino_path}/hardware/arduino/avr",
"arduino_avr_include2_path": "${env:arduino_path}/hardware/tools/avr/avr/include",
"arduino_avr_compiler_path": "${env:arduino_path}/hardware/tools/avr/bin/avr-g++"
},
"configurations": [
{
"name": "Mac",
"defines": [
"ARDUINO=10810",
"__AVR_ATmega328P__",
"UBRRH"
],
"includePath": [
"${workspaceRoot}",
"${env:arduino_avr_include_path}/**",
"${env:arduino_avr_include2_path}/**"
],
"forcedInclude": [
"/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h"
],
"intelliSenseMode": "gcc-x64",
"cStandard": "c11",
"cppStandard": "c++11",
"compilerPath": "${env:arduino_compiler_path} -std=gnu++11 -mmcu=atmega328p"
}
],
"version": 4
}
The key to finding <avr/pgmspace.h> was the adding the hardware/tools/avr/avr/include path.
Defining ARDUINO=10810 was identified from the output of running Arduino: Verify with the verbose flag.
Defining __AVR_ATmega328P__ was added to allow proper IntelliSense completion of the raw register macros (e.g. _BV(), OCR0A, TIMSK0, etc.); the correct macro to define was identified based on the chip being an ATMEGA328P-PU and by inspection of the file hardware/tools/avr/avr/include/avr/io.h.
The compilerPath value looks wrong, although it is only used by the IDE and not for target compilation. The documentation says :
The absolute path to the compiler you use to build your project. The extension will query the compiler to determine the system include paths and default defines to use for IntelliSense.
In any case I recommend to configure it properly, I was able to remove
"${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/../lib/gcc/avr/5.4.0/include",
"${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/../lib/gcc/avr/5.4.0/include-fixed",
"${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/../lib/gcc/avr/5.4.0/../../../../avr/include"
when setting
"compilerPath": "${HOME}/.arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-g++ -std=gnu++11 -mmcu=atmega328p",
To figure out the exact compiler that is used turn on verbose logging in the output window:
File -> Preferences -> Settings -> Extensions -> Arduino configuration -> Log level -> verbose
which in this case also should help you figure out why the compiler does not pick up avr/pgmspace.h.
Here are my arduino.json
{
"board": "arduino:avr:uno",
"port": "/dev/ttyUSB0",
"sketch": "src/myproject.ino",
"output": "../build"
}
and c_cpp_properties.json
{
"env": {
"arduino.path": "${HOME}/.arduino15/packages/arduino",
"arduino.avr.include.path": "${env:arduino.path}/hardware/avr/1.6.23",
"arduino.avr.compiler.path": "${env:arduino.path}/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/avr-g++",
"arduino.libraries.path": "${HOME}/arduino/sketchbook/libraries",
"dummy-last-line": "To allow the second to last line (e.g. the real last line) to always end with a comma"
},
"configurations": [
{
"name": "Linux",
"includePath": [
"./src",
"./test",
"../arduino_ci/cpp/unittest",
"${env:arduino.libraries.path}/SmartLCD",
"${env:arduino.libraries.path}/Chronos/src",
"${env:arduino.libraries.path}/Time",
"${env:arduino.libraries.path}/RTClib",
"${env:arduino.avr.include.path}/libraries/Wire/src",
"${env:arduino.avr.include.path}/cores/arduino",
"${env:arduino.avr.include.path}/variants/standard"
],
"browse": {
"path": [
"${workspaceFolder}/src"
],
"limitSymbolsToIncludedHeaders": true
},
"defines": [
"UBRRH"
],
"intelliSenseMode": "gcc-x64",
"compilerPath": "${env:arduino.avr.compiler.path} -std=gnu++11 -mmcu=atmega328p",
"cStandard": "c11",
"cppStandard": "c++11"
}
],
"version": 4
}
(the UBRRH define is for the Serial variable in HardwareSerial.h)
I want to transpile both typescript and sass to javascript and css respectively. At The moment running this tasks.json file transpiles my typescript to javascript:
{
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "tsc",
// The command is a shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// args is the HelloWorld program to compile.
"args": ["public/app/boot.ts"],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
I only need to specify boot.ts and it transpiles all .ts files to js. It might be because my boot.ts file imports all my ts files. Here is my boot.ts file:
import {bootstrap} from 'angular2/platform/browser'
import {HelloWorld} from './hello_world'
import {TodoApp} from './todo_app'
bootstrap(HelloWorld);
bootstrap(TodoApp);
I would like to add code into the tasks.json file that will transpile the sass to css.
Here is a code snippet of what I could do to only transpile my sass:
{
"version": "0.1.0",
"command": "node-sass",
"isShellCommand": true,
"args": ["styles.scss", "styles.css"]
}
How do I add that code snippet so that it transpiles both the sass and the typescript?
Also, Will I be wanting to add any new sass files to the args array in tasks.json as I create them?
you can't do this with the tsc command. use npm instead.
package.json
{
"scripts": {
"build": "tsc public/app/boot.ts && node-sass styles.scss styles.css"
}
}
tasks.json
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"showOutput": "silent",
"args": ["-s", "run"],
"tasks": [{
"taskName": "build",
"problemMatcher": "$tsc",
"isBuildCommand": true
}]
}
I'm not sure when this feature was added, so it may not of helped the OP. I like this because it's built-in to the IDE. For the OP case they just need to decide which should be completed before the other.
The following snippet allows multiple tasks to be run, one after the other. A pre-build, build, and post-build, when building your project select the "Pre-Build & Build & Post-Build" to run them all. This is still a rather simple chain of tasks, and you could create multiple chains of any length with this technique, but they do tend to clutter up the tasks.json file.
"tasks": [
{
"label": "base",
"detail": "Pre-Build",
"type": "shell",
"command":["echo"],
"args": ["prebuild task"],
},
{
"label": "build",
"detail": "Pre-Build & Build",
"type": "shell",
"command":["echo"],
"args": ["build task"],
"dependsOn":["base"],
},
{
"label": "Post Build",
"detail": "Pre-Build & Build & Post-Build",
"type": "shell",
"command":["echo"],
"args": ["Post build task"],
"dependsOn":["build"],
}
]