I have a fresh laravel 9 project
I want to create an auth system with laravel command by using
composer require laravel/ui
and also
php artisan ui bootstrap --auth
after that I did
npm install
npm run dev
but rather that opening a mix development to generate css styles of auth pages it gave me this output in terminal
npm run dev image
and the page style is being like this
Page styles
I found the solution for this problem
the problem was in the package.json file
package.json was like this:
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"#popperjs/core": "^2.10.2",
"axios": "^0.25",
"bootstrap": "^5.1.3",
"laravel-mix": "^6.0.49",
"laravel-vite-plugin": "^0.4.0",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"sass": "^1.32.11",
"sass-loader": "^11.0.1",
"vite": "^2.9.11"
}
}
As you can see the dev in script was applied to vite,
"scripts": {
"dev": "vite",
"build": "vite build"
}
I just modified vite to mix and run
npm install again
and the problem was resolve and tyles of my login page generated successfully
Styles result
Update - ## Better Solution:
Installing Laravel/ui
composer require laravel/ui
Install Bootstrap Auth Scaffold
php artisan ui bootstrap --auth
In Vite.config file
import path by adding this at top:
import path from 'path';
after plugins add this:
resole: {
alias: {
'~bootstrap': path.resolve(__dirname, 'node_module/bootstrap'),
}
}
final result of vite config file will be like this:
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import path from 'path';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/sass/app.scss',
'resources/js/app.js',
],
refresh: true,
}),
],
resole: {
alias: {
'~bootstrap': path.resolve(__dirname, 'node_module/bootstrap'),
}
}
});
From resources/js/app.js - add these lines
import '../sass/app.scss';
import * as boostrap from 'bootstrap'
Final Result of resources/js/app.js will be like this
import './bootstrap';
import '../sass/app.scss';
import * as boostrap from 'bootstrap'
Final Step is to change styles and script to #vite directive in resources/view/layouts/app.blade.php
change any css or js files from this type
<link href="{{asset('css/app.css')}}" rel="stylesheet" />
to #vite directive type
#vite(['resources/css/app.css', 'resources/css/app.css'])
Make sure you already have those files before trying to include it, otherwise vite will cause an error.
Related
My site uses Vue, Bootstrap, and Vuetify. It works locally. I deployed it on Netlify and Heroku with the same result. index.html runs, but not Vue. Bootstrap failed.
Here are 2 methods of deploying Bootstrap that work locally and their links. Method 1 fails.
Import locally.
Netlify
In main.js:
import 'bootstrap'
import 'bootstrap/dist/css/bootstrap.min.css'
Import from a CDN.
Netlify Heroku
In index.html:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css"
integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
Deployment steps:
For Heroku, I followed steps here with the below changes:
Commands I used in step 3:
npm run build
git add .
git commit -m "deploy"
I added a name to the app in step 4.
After deploying to Heroku, I had a dist folder directory. For Netlify, I dragged this to a box that said "Drag and drop your site folder here".
This is in package.json:
"scripts": {
"start": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
Michal Levý's answer worked. I set publicPath when following a tutorial.
I commented it out in vue.config.js.
module.exports = {
"transpileDependencies": [
"vuetify"
],
// publicPath: process.env.NODE_ENV === 'production'
// ? '/skillportfolios/'
// : '/'
}
I got it working here in Netlify, but not Heroku. That's good enough.
I created a new vue project with the vue cli and then adjusted main.js to support web-components:
import Vue from 'vue';
import wrap from '#vue/web-component-wrapper';
import HelloWorld from "./components/HelloWorld";
const CustomElement = wrap(Vue, HelloWorld);
window.customElements.define('my-custom-element', CustomElement);
When running vue-cli-service build --target wc I get the following error:
ERROR Vue 3 support of the web component target is still under development.
I can not figure out why this error occurs and what i can do to fix it.
package.json:
...
"dependencies": {
"#vue/web-component-wrapper": "^1.2.0",
"core-js": "^3.6.5",
"vue": "^3.0.2"
},
"devDependencies": {
"#vue/cli-plugin-babel": "~4.5.0",
"#vue/cli-plugin-eslint": "~4.5.0",
"#vue/cli-service": "^4.5.4",
"#vue/compiler-sfc": "^3.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0-0"
},
...
I use #vue/cli version 4.5.9.
Hello there is a update in this. Topic see
issue on github and comment on twitter looks like with vue 3.2.0 we have this feature back i created a small stackblitz but as you can see styles are not applied
Vue-CLI does not currently support web components for Vue 3, but you can do it by hand. This worked for me.
src/MyLib.js
export { default as TheFoo } from '#/components/TheFoo.vue';
export { default as TheBar } from '#/components/TheBar.vue';
src/MyLib-WC.js
import { defineCustomElement } from 'vue';
import TheFoo from '#/components/TheFoo.vue';
import TheBar from '#/components/TheBar.vue';
const TheFooWC = defineCustomElement(TheFoo);
const TheBarWC = defineCustomElement(TheBar);
export {
TheFooWC,
TheBarWC
};
export function register () {
customElements.define('the-foo', TheFooWC);
customElements.define('the-bar', TheBarWC);
}
package.json
{
"scripts": {
"build": "npm run build-lib && npm run build-wc",
"build-lib": "vue-cli-service build --name=MyLib --modern --dest=dist/lib --target=lib src/MyLib.js",
"build-wc": "vue-cli-service build --name=MyLib --modern --dest=dist/wc --target=lib --inline-vue src/MyLib-WC.js"
}
}
Then npm run build.
As #tony19 pointed out the solution is to not use Vue3, as it cureently does not support web components.
The problem for me was the misleading error message, as "still under developement" did not signal to me, that web components were completly unsupported. I understood it, as a "not everything will work perfectly".
I have a moderately simple example of a React Hooks widget whose function it is to provide context hooks to provide state that can set a few strings and switch the current Material UI theme. Here is the working demo. By clicking on the button labeled "NEXT THEME" you can see the page toggle between yellow and blue, along with some text changes indicating the name of the theme.
Its a contrived example, but the idea is that at the top of my site, I'm wrapping all content with context providers so that any nested widget can access shared state. Looks like this:
import React from "react";
import { AppContext } from "./AppContext";
import { ThemeContextProvider } from "./ThemeContext";
export default function App(props) {
return (
<div>
<ThemeContextProvider>
<AppContext>{props.children}</AppContext>
</ThemeContextProvider>
</div>
);
}
Everything is working as I said in the demo I've linked above. But when I publish this code to NPM and then use it in another project, it mostly works except for one import piece--the theme color will not change. All other state changes work right--all of the other state changes are textual and there are no problems, but the color will not change.
The theme is provided by Material UI, and I suspect that there is an issue with the way that I am rolling all this code up for publishing to NPM. I am using Rollup--here is rollup.config.js:
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import external from 'rollup-plugin-peer-deps-external';
import resolve from 'rollup-plugin-node-resolve';
import json from '#rollup/plugin-json';
const {terser} = require('rollup-plugin-terser');
import pkg from './package.json';
export default {
input: 'src/index.js',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true
},
{
file: pkg.module,
format: 'es',
sourcemap: true
}
],
plugins: [
external(),
// url({ exclude: ['**/*.svg'] }),
babel({
exclude: 'node_modules/**',
runtimeHelpers: true
}),
resolve({
preferBuiltins: true,
browser: true
}),
commonjs({
include: 'node_modules/**',
browser: true,
namedExports: {
'node_modules/react/index.js': [
'createContext',
'useContext',
'useEffect',
'useState'
],
'node_modules/react-is/index.js': [
'ForwardRef',
'Memo'
],
'node_modules/prop-types/index.js': [
'elementType'
]
}
}),
terser(),
json()
]
};
And here is my package.json:
{
"name": "#data-factory/theme-context-test",
"version": "0.0.1",
"description": "Code from CodeSandbox",
"author": "sellis42",
"main": "dist/index.js",
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",
"engines": {
"node": ">=8",
"npm": ">=5"
},
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "rollup -c",
"start": "rollup -c -w",
"prepare": "npm run build",
"predeploy": "cd example && npm install && npm run build"
},
"peerDependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0"
},
"devDependencies": {
"#babel/core": "^7.9.0",
"#babel/plugin-transform-runtime": "^7.9.0",
"#babel/preset-env": "^7.9.0",
"#babel/preset-react": "^7.0.0",
"#babel/runtime": "^7.9.2",
"#material-ui/core": "^4.9.8",
"#material-ui/icons": "^4.9.1",
"#material-ui/styles": "^4.9.6",
"#rollup/plugin-json": "^4.0.2",
"cross-env": "^5.2.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "^3.4.0",
"rollup": "^1.32.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^4.2.4",
"rollup-plugin-peer-deps-external": "^2.2.2",
"rollup-plugin-terser": "^4.0.4",
"typeface-roboto": "0.0.75"
}
}
I feel as if there is something missing from my rollup configuration. This project is on my local development system and is slightly different that the linked code. I essentially have all the code that I publish in the root of the widget module, and an example folder that demonstrates how to use the widget. I use npm link so that the example widget can use it, and that is where I see the issue I'm trying to resolve. I can copy the entire root widget to a subfolder of the example src and import it from there instead of from NPM and it works again.
Any help or ideas would be appreciated. I can put all of my code to Git if anyone is interested in taking a deeper look.
I've sidestepped the issue altogether by not using a ThemeProvider in the ThemeContext. Here is what is returned by the ThemeContext hook (source abbreviated):
return (
<ThemeContext.Provider value={{theme, setTheme ... }}>
<ThemeProvider theme={theme}>{props.children}</ThemeProvider>
</ThemeContext.Provider>
);
I changed this to:
return (
<ThemeContext.Provider value={{theme, setTheme ... }}>
{props.children}
</ThemeContext.Provider>
);
It is the responsibility of children then to supply a ThemeProvider. As long as I avoid providing the ThemeProvider in my hooks I seem to be ok.
I'm not sure why this is, but I can live with it.
I am trying to use Expo's Print.printToFileAsync(options but I keep on getting [Unhandled promise rejection: TypeError: undefined is not an object (evaluating '_expoPrint.Print.printToFileAsync')].
I looked for a lot of solutions online but couldn't find a solution to this. I started using React Native libraries but as I searched, turns out I can only use Expo's library so I switched to Print.printToFileAsync().
App.js
import React, {Component} from 'react';
import { StyleSheet, Text, View, TouchableHighlight } from 'react-native';
import { Print } from 'expo-print';
export default class App extends Component {
async createPDF() {
let filePath = await Print.printToFileAsync({
html: "<h1>PDF TEST</h1>",
width : 612,
height : 792,
base64 : false
});
alert('PDF Generated', filePath.uri);
}
render() {
return(
<View>
<TouchableHighlight onPress={this.createPDF} style={styles.Main}>
<Text>Create PDF</Text>
</TouchableHighlight>
</View>
)
}
}
const styles = StyleSheet.create({
Main : { marginTop : 100 }
});
Package.JSON
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "^33.0.0",
"expo-print": "^5.0.1",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
"react-native-html-to-pdf": "^0.7.0",
"react-native-share": "^1.2.1",
"react-native-web": "^0.11.4"
},
"devDependencies": {
"babel-preset-expo": "^5.1.1"
},
"private": true
}
My end goal is to make a PDF file using HTML in my Expo project.
Please use -
import * as Print from 'expo-print';
instead of -
import { Print } from 'expo-print';
The Expo sdk33 requires the module to be installed and run directly.
expo install expo-print
Modular Imports
With SDK 33, we’re deprecating imports of most modules from the expo package. This means that in a future release, you won’t be able to write, for example, import { FileSystem } from 'expo';. Rather, you’ll need to install the individual packages for each module you use and import from them instead.
You can use the new expo install command to install modules; this command is a wrapper around npm install/yarn add that automatically installs a module version compatible with your SDK version. For example, for the FileSystem module, you would run expo install expo-file-system and then use import * as FileSystem from 'expo-file-system';. This change paves the way for tree-shaking and smaller JavaScript bundles. It also makes moving between the managed and bare workflows simpler.
Imports from the expo package will continue to work in SDK 33 but will generate a warning in the console, and you’ll need to import from the individual packages to make the warning disappear. To make this change easier, we’re providing a codemod that’ll automatically update all of your imports for you.
Home page with description of SDK33
follow this link https://stackoverflow.com/a/71569236/14448694
import * as Print from "expo-print"; import { shareAsync } from "expo-sharing";
I wanted to try out the react-native-ble-plx library from Polidea
https://github.com/Polidea/react-native-ble-plx
So I created a new app in terminal and installed the library as explained by Polidea
create-react-native-app playground
npm install --save react-native-ble-plx
react-native link react-native-ble-plx
I then ran npm start and then i (for opening in iOS simulator)
and then I got the following error (in the terminal and in the simulator)
Native module cannot be null
node_modules/react-native/node_modules/fbjs/lib/invariant.js:44:24 in invariant
node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js:31:16 in NativeEventEmitter
node_modules/react-native-ble-plx/src/BleManager.js:52:25 in BleManager
App.js:8:19 in App
node_modules/react-native/Libraries/Renderer/ReactNativeStack-dev.js:1679:33 in
node_modules/react-native/Libraries/Renderer/ReactNativeStack-dev.js:1610:15 in measureLifeCyclePerf
... 52 more stack frames from framework internals
Here is the code in App.js:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import {BleManager} from 'react-native-ble-plx';
//importing BleManager without calling new BleManager() works
export default class App extends React.Component {
constructor(){
super();
this.manager = new BleManager();
}
//calling new BleManager() leads to error
render() {
return (
<View style={styles.container}>
<Text>nothing, just sucking errors</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Here is the file package.json
{
"name": "playground",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.5.0",
"jest-expo": "^21.0.2",
"react-test-renderer": "16.0.0-alpha.12"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js --watch"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"expo": "^21.0.0",
"react": "16.0.0-alpha.12",
"react-native": "^0.48.4",
"react-native-ble-plx": "^0.6.3"
}
}
I already looked for help and tried
npm -rm rf node_modules
npm install
but it didn't help.
Here is my system information:
macOS High Sierra
iMac (27-inch, Mid 2010)
Processor 2.8 GHz Intel Core i5
Memory 16 GB 1333 MHz DDR3
I also got the same error when opening the app in my iPhone(6s, 10.3.1) (after scanning QR code in terminal from npm start)
Other apps without the react-native-ble-plx library work normally.
Looking forward receiving some help.
Thanks in advance.
Frank
You have used create-react-native-app to create your React Native project. So you can not use react-native-ble-plx library with this project. Because to access Bluetooth hardware, react-native-ble-plx package has some native code written in android and ios seperately.
If you want to build your app, you'll need to eject from create-react-native-app and use Xcode and Android Studio.
Use the below command:--
npm install -g react-native-cli
npm run eject
react-native link react-native-ble-plx
1st command is to install react-native-cli globally
2nd command is to convert your project from Expo project to regular React Native project
3rd command is to link react-native-ble-plx. Because most probably your previous link was failed.
What I did was (after completely removing ble-plx by discarding git changes before I started)
navigating to /node_modules/react-native-ble-plx/ios/BleClient.xcodeproj and
I pulled that into the Libraries folder in the project navigator
Then I went to my target -> build phases -> link binary with libraries and added libBleClient.a