I am a newbiew of ReactJS. Before, I used ReactJS for my company's project but actually that project has configurated by somone. I just apply what I know about Reactjs into project such as : state, props, component, apply redux.....
But , now I want to create a project by myself step by step. In that I can use reactjs integrate redux to manage state for using data and Spring is server in RESTfull standard and combine with JPA
Please help me
You can integrate spring and react js using 2 approaches
You can do it by making an isomorphic web app which uses nashorn engine(jdk8).
You can use pusher api(I have used pusher api in my app)
As i can not explain the full working here,here are tutorials for reference
using pusher api
isomorphic wb app
There is no simple answer.
You can use maven plugin https://github.com/eirslett/frontend-maven-plugin
Add to your pom.xml something like this
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<installDirectory>target</installDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v4.4.5</nodeVersion>
<npmVersion>3.9.2</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>webpack build</id>
<goals>
<goal>webpack</goal>
</goals>
</execution>
</executions>
</plugin>
and you need to add package.json like this
{
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2",
"requirejs": "^2.3.2"
},
"devDependencies": {
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-plugin-transform-regenerator": "^6.22.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.22.0",
"babel-preset-stage-0": "^6.22.0",
"react-frame-component": "^0.6.6",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.3.0"
},
"scripts": {
"start": "webpack-dev-server --progress --inline --hot",
"build": "webpack -d"
}
}
But list of dependenccies is yours
And you need webpack.config.js something like this
var path = require('path');
var webpack = require('webpack');
var packageJSON = require('./package.json');
module.exports = {
entry: [
'webpack/hot/only-dev-server',
'./src/main/resources/static/App.js'],
devtool: 'sourcemaps',
cache: true,
output: {
path: __dirname,
filename: './src/main/resources/static/built/bundle.js',
publicPath: 'http://localhost:3000/'
},
resolve: {extensions: ['.js', '.jsx']},
plugins: [
new webpack.HotModuleReplacementPlugin()
,new webpack.LoaderOptionsPlugin({
debug: true
})
],
module: {
loaders: [
{
test: path.join(__dirname, '.'),
exclude: /(node_modules)/,
loader: 'babel-loader',
query: {
cacheDirectory: true,
presets: ['es2015', 'react']
}
},
]
},
devServer: {
noInfo: false,
quiet: false,
lazy: false,
watchOptions: {
poll: true
}
}
};
Related
Hi,
I'm trying to build an app using Tailwind and NextJs with some style in SCSS. Everything was working find and I was tweaking some Tailwind class in my components until the app suddenly crashed with this message
./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[3].oneOf[10].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[3].oneOf[10].use[2]!./node_modules/next/dist/build/webpack/loaders/resolve-url-loader/index.js??ruleSet[1].rules[3].oneOf[10].use[3]!./node_modules/next/dist/compiled/sass-loader/cjs.js??ruleSet[1].rules[3].oneOf[10].use[4]!./styles/globals.scss
TypeError: Cannot read properties of undefined (reading '5')
It appeared just like this, it worked for 3 hours and then just stopped, I did not changed any config files or anything else. I don't understand. After some time looking trough my code I've found that if I remove these import at the top of my global.scss the app works fine, but I don't know where this undefined variable is..
#tailwind base;
#tailwind components;
#tailwind utilities;
here is my tailwind config
module.exports = {
purge: ['./pages/**/*.{js,ts,jsx,tsx}', './components/**/*.{js,ts,jsx,tsx}'],
darkMode: false,
theme: {
extend: {
spacing: {
'2/3': '66.666667%',
},
colors: {
'lavander-grey': '#625F63',
'lavander-indigo': '#9893DA'
},
},
},
variants: {
extend: {},
},
plugins: [],
};
package.json
"engines": {
"node": ">=14.0"
},
"engineStrict": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"graphql": "^16.6.0",
"graphql-request": "^5.0.0",
"html-react-parser": "^3.0.4",
"moment": "^2.29.4",
"next": "13.0.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-multi-carousel": "^2.8.2",
"sass": "^1.56.1",
"swr": "^1.3.0"
},
"devDependencies": {
"autoprefixer": "^10.4.13",
"eslint": "^8.27.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-next": "13.0.3",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.31.10",
"eslint-plugin-react-hooks": "^4.6.0",
"postcss": "^8.4.19",
"tailwindcss": "^3.2.4"
Postcss.config.js
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
thanks for your help
I've tried to install some older Tailwind packages, wiped node_modules, made sure this was not my components the culprit, tried some Tailwind configurations,started a fresh dev server, did some intense googling
Tailwind is no longer using PurgeCSS under the hood with the release of their JIT compiler as of Tailwind 3.0.
Update the first line of your config to:
content: [
"./app/**/*.{js,ts,jsx,tsx}",
"./pages/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
],
As shown in the docs, and be sure to include a postcss.config.js file.
In order to write those:
#tailwind base;
#tailwind components;
#tailwind utilities;
you need to install postcss. 'postcss` is like webpack, uses plugins and evaluates them to modern CSS syntax that browser understand
npm install -D tailwindcss postcss autoprefixer postcss-nesting
Then you should have postcss.config.js and have this config:
module.exports = {
plugins: ["tailwindcss", "postcss-nesting", "autoprefixer"],
};
In my maven pom I have:
<properties>
<suppressions>./suppressions.json</suppressions>
</properties>
<plugin>
<groupId>dev.iabudiab</groupId>
<artifactId>dependency-track-maven-plugin</artifactId>
<version>2.1.0</version>
</plugin>
And in the root of my project I have a suppressions.json like this:
{
"suppressions": [
{
"by": "cve",
"cve": "CVE-2020-7019",
"expiration": "2024-12-31",
"note": "Bladi bla, reason because bladi"
}
]
}
Yet, after my build in Bamboo I still see CVE-2020-7019 between the vulnerabilities.
I am currently using Angular 6, .NET core 2.1, VS 2017. Before upgrading to Angular 6, I was using Angular 4. Breakpoints in TS files were working fine. I have upgraded to Angular 6, after that none of the TS breakpoints are working.
Getting the below hint on the breakpoint.
The breakpoint will not currently be hit. No symbols have been loaded for this document.
Here is my packages.json file:
"scripts": {},
"devDependencies": {
"#angular/animations": "6.1.0",
"#angular/cli": "^6.1.1",
"#angular/common": "6.1.0",
"#angular/compiler": "6.1.0",
"#angular/compiler-cli": "6.1.0",
"#angular/core": "6.1.0",
"#angular/forms": "6.1.0",
"#angular/http": "6.1.0",
"#angular/platform-browser": "6.1.0",
"#angular/platform-browser-dynamic": "6.1.0",
"#angular/platform-server": "6.1.0",
"#angular/router": "6.1.0",
"#ngtools/webpack": "^6.1.1",
"#types/chai": "4.1.4",
"#types/jasmine": "2.8.8",
"#types/webpack-env": "1.13.6",
"angular2-router-loader": "0.3.5",
"angular2-template-loader": "0.6.2",
"aspnet-prerendering": "^3.0.1",
"aspnet-webpack": "^3.0.0",
"awesome-typescript-loader": "5.2.0",
"bootstrap": "4.1.3",
"chai": "4.1.2",
"css": "2.2.3",
"css-loader": "1.0.0",
"es6-shim": "0.35.3",
"event-source-polyfill": "0.0.12",
"expose-loader": "0.7.5",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.11",
"html-loader": "0.5.5",
"isomorphic-fetch": "2.2.1",
"jasmine-core": "3.1.0",
"jquery": "3.3.1",
"json-loader": "0.5.7",
"karma": "2.0.5",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-jasmine": "1.1.2",
"karma-webpack": "3.0.0",
"popper.js": "^1.12.9",
"preboot": "6.0.0-beta.4",
"raw-loader": "0.5.1",
"reflect-metadata": "0.1.12",
"rxjs": "6.2.2",
"style-loader": "0.21.0",
"to-string-loader": "1.1.5",
"typescript": "2.9.2",
"url-loader": "1.0.1",
"webpack": "^4.16.3",
"webpack-cli": "^3.1.0",
"webpack-hot-middleware": "2.22.3",
"webpack-merge": "4.1.3",
"zone.js": "0.8.26"
},
"dependencies": {
"ng-bootstrap": "^1.6.3",
"ngx-loading": "^1.0.14",
"ngx-pagination": "^3.1.1",
"npm": "^6.2.0",
"w3-css": "^4.1.0"
}
Here is my webpack config file
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const AotPlugin = require('#ngtools/webpack').AotPlugin;
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
module.exports = (env) => {
// Configuration in common to both client-side and server-side bundles
const isDevBuild = !(env && env.prod);
const sharedConfig = {
stats: { modules: false },
context: __dirname,
resolve: { extensions: ['.js', '.ts'] },
output: {
filename: '[name].js',
publicPath: 'dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix
},
module: {
rules: [
{ test: /\.ts$/, use: isDevBuild ? ['awesome-typescript-loader?silent=true', 'angular2-template-loader', 'angular2-router-loader'] : '#ngtools/webpack' },
{ test: /\.html$/, use: 'html-loader?minimize=false' },
{ test: /\.css$/, use: ['to-string-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize'] },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
]
},
mode:'development',
plugins: [new CheckerPlugin(),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core/,
path.resolve(__dirname, './ClientApp')
)]
//,
//performance: {
// maxEntrypointSize: 512000,
// maxAssetSize: 512000
//}
};
// Configuration for client-side bundle suitable for running in browsers
const clientBundleOutputDir = './wwwroot/dist';
const clientBundleConfig = merge(sharedConfig, {
entry: { 'main-client': './ClientApp/boot.browser.ts' },
output: { path: path.join(__dirname, clientBundleOutputDir) },
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json')
})
].concat(isDevBuild ? [
// Plugins that apply in development builds only
new webpack.SourceMapDevToolPlugin({
filename: '[file].map', // Remove this line if you prefer inline source maps
moduleFilenameTemplate: path.relative(clientBundleOutputDir, '[resourcePath]') // Point sourcemap entries to the original file locations on disk
})
] : [
// Plugins that apply in production builds only
new webpack.optimize.UglifyJsPlugin(),
new AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'ClientApp/app/app.browser.module#AppModule'),
exclude: ['./**/*.server.ts']
})
])
});
// Configuration for server-side (prerendering) bundle suitable for running in Node
const serverBundleConfig = merge(sharedConfig, {
resolve: { mainFields: ['main'] },
entry: { 'main-server': './ClientApp/boot.server.ts' },
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./ClientApp/dist/vendor-manifest.json'),
sourceType: 'commonjs2',
name: './vendor'
})
].concat(isDevBuild ? [] : [
// Plugins that apply in production builds only
new AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'ClientApp/app/app.server.module#AppModule'),
exclude: ['./**/*.browser.ts']
})
]),
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, './ClientApp/dist')
},
target: 'node',
devtool: 'inline-source-map'
});
return [clientBundleConfig, serverBundleConfig];
};
Help me in fixing this issue.
TS breakpoints are not working after upgrading to Angular 6 in VS 2017
This is a known issue for .NET core 2.1, which reported by many other communities on Developer Community:
TS breakpoints not working with ASP.NET Core 2.1
MS develop team has fixed the problem the latest 15.9 Preview release for Visual Studio. You can download the latest preview from the following URL ( https://visualstudio.microsoft.com/vs/preview/ ).
Meanwhile, they recommended workaround is for developers to target .NET core SDK 2.0 when creating a new project and after project creation update the project target runtime to 2.1.
Hope this helps.
Try deleting vs folder near sln file. Also make sure your debug options are set correctly and Javascript debugging is enabled. I had similar issue with chrome but in IE it was working fine. After I upgraded my vs 2017, on running my website it asked me if i want to enable java script debugging. After clicking yes, I was able to debug in chrome. My guess is that there is some setting in vs which has to be enabled for chrome ja debugging
I have an existing ExtJS app developed using ExtJS 4.2.1.
I am using Closure minifier through Maven plugin minify-maven-plugin.
The generated minified JS files (without merge) works fine.
However, generated merged minified file throws undefined errors because the definition comes later in the merged file.
My question is, is there a way I can figure out the order I have to provide the plugin? (I don't want to use Sencha Cmd)
The app folder follows the structure
app/common, app/controller, app/model, app/proxy, app/store, app/utils, app/view
At the moment this is how I have defined the build process in Maven POM file
<plugins>
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.7.4</version>
<executions>
<execution>
<id>default-minify</id>
<phase>prepare-package</phase>
<goals>
<goal>minify</goal>
</goals>
<inherited>false</inherited>
<configuration>
<charset>UTF-8</charset>
<!-- <skipMerge>true</skipMerge> -->
<webappSourceDir>${basedir}/src/main</webappSourceDir>
<jsSourceDir>js/app</jsSourceDir>
<jsTargetDir>js/app</jsTargetDir>
<jsEngine>CLOSURE</jsEngine>
<closureLanguage>ECMASCRIPT5</closureLanguage>
<closureAngularPass>true</closureAngularPass>
<nosuffix>true</nosuffix>
<webappTargetDir>${project.build.directory}</webappTargetDir>
<jsSourceIncludes>
<jsSourceInclude>**/*.js</jsSourceInclude>
</jsSourceIncludes>
</configuration>
</execution>
</executions>
</plugin>
Why dont use Sencha Cmd? It does exactly what you want!
Maybe it helps if you know that you can use Sencha Cmd without the Sencha application structure. If you want only merge the files use the concatenate cmd.
If you really dont want use Sencha Cmd, then you have to take care of all the extends, requires, mixins and so on... and I would not recommend this!
For example use Sencha Cmd with manual paths and exclude the extjs classes
sencha compile --classpath=myApp/src,extjs/src -debug=false exclude -all and include -namespace MyApp.* and concat bundle.js
the extjs/src path is the path where your extjs classes are
Since your question is about the order of of files for minification, providing that information below:
We had a similar requirement, where I could not use Sencha cmd as it is to minify files, so created jsb file on my own [I know this is not recommended :( ].
What I did was, created below jsb file [please note: sequence of files is very important]:
{
"projectName": "ProductName",
"builds": [
/** This file is for production purpose **/
{
"name": "ProductName - Production",
"target": "all-app.js",
"compress": true,
"files": [
/** utils **/
{
"path": "app/util/",
"name": "util.js"
}
/** models **/
{
"path": "app/model/",
"name": "MyModel.js"
},
/** stores **/
{
"path": "app/store/",
"name": "MyStore.js"
},
/** custom components **/
{
"path": "resources/ux/form/",
"name": "MySearchField.js"
},
/** views **/
{
"path": "app/view/admin/",
"name": "MyView.js"
},
/** controllers **/
{
"path": "app/controller/",
"name": "Window.js"
},
/** app.js **/
{
"path": "",
"name": "app.js"
}
]
},
/** This file is for debug purpose **/
{
"name": "ProductName - debug",
"target": "all-app-debug.js",
"compress": false,
"files": [
/** utils **/
{
"path": "app/util/",
"name": "util.js"
}
/** models **/
{
"path": "app/model/",
"name": "MyModel.js"
},
/** stores **/
{
"path": "app/store/",
"name": "MyStore.js"
},
/** custom components **/
{
"path": "resources/ux/form/",
"name": "MySearchField.js"
},
/** views **/
{
"path": "app/view/admin/",
"name": "MyView.js"
},
/** controllers **/
{
"path": "app/controller/",
"name": "Window.js"
},
/** app.js **/
{
"path": "",
"name": "app.js"
}
]
}
],
"resources" : []
}
If you create a minified file using above sequence, it will work in your case as well.
Hope this help.
Thanks!
I am currently using lesscss-maven-plugin by org.codehaus.mojo;
the build is ok, and it is compiling properly.
How ever I am not generating any source map:
on my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<force>true</force>
<lessJs>${project.basedir}/src/main/resources/lessjs/less.1.7.5-min.js</lessJs>
<sourceDirectory>${project.build.directory}/${project.build.finalName}/</sourceDirectory>
<outputDirectory>${project.build.directory}/${project.build.finalName}-LESS</outputDirectory>
<compress>true</compress>
<includes>
<include>r/assets/bootstrap.less</include>
<include>r/assets/page.less</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<phase>prepare-package</phase>
</execution>
</executions>
</plugin>
on the less.js I added this at the top:
less: {
env: "development",
"development": {
options: {
compress: true,
yuicompress: true,
optimization: 2,
sourceMap: true,
sourceMapFilename: "r/css/styles.map"
},
files: {
"r/css/bootstrap.css": "r/assets/bootstrap.less",
"r/css/page.css": "r/assets/page.less",
}
}
}
Did I forgot something? TIA.