CSS minification error in npm run build [vue.js] - vue.js

Im receiving this error everytime I try to run 'npm run build' and I dont have any css file.
ERROR Error: CSS minification error: Unexpected ":" found.. File: css/app.86f0ef2e.css
Error: CSS minification error: Unexpected ":" found.. File: css/app.86f0ef2e.css
at C:\Users\LesterKingsley\OneDrive\Desktop\vuewuna\dos\node_modules#intervolga\optimize-cssnano-plugin\index.js:106:21
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Promise.all (index 0)
I'm new to vue, I don't have a clue to solve this problem.

I faced this same error last week, and this is my solution to it. I'm not sure if it's going to work for you though.
What I did basically was these;
I found and removed the file that course the error (in my case public/css/argon.css) then I cut out all the codes inside of that file and saved.
Then I ran npm run build and it built successfully.
After the build process had completed, I then pasted the codes inside of the file (in my case dist/css/argon.css) and the vuejs created css.
That solved the problem.
Pls give a thumbs up if that works for you.

The problem is sometimes in the ::v-deep label:
// WRONG:
::v-deep(.some-class) { ... }
// READY:
::v-deep .some-class { ... }

Please comment all your internal css. This work for me successfully.
I too did not have any external css file. But the issues were in my internal files.
This is the line that cause the error text-align: calc();

I got this error.
For me the problem was this:
input['text'],
input['email'] {
user-select: initial;
}

Related

How to prerender a Vue3 application?

I try without success to apply a prerendering (or a SSG) to my Vue3 application to make it more SEO friendly.
I found the vue-cli-plugin-prerender-spa, and when I try it with the command line: vue add prerender-spa I have the error:
ERROR TypeError: Cannot read properties of undefined (reading 'endsWith')
After that I tried prerender-spa-plugin but I have an error when I make a npm run build:
[prerender-spa-plugin] Unable to prerender all routes!
ERROR Error: Build failed with errors.
Error: Build failed with errors.
at /Users/myusername/Workspace/myproject/node_modules/#vue/cli-service/lib/commands/build/index.js:207:23
at /Users/myusername/Workspace/myproject/node_modules/webpack/lib/webpack.js:148:8
at /Users/myusername/Workspace/myproject/node_modules/webpack/lib/HookWebpackError.js:68:3
What do you think about this? Do you have any idea?
Nuxt3 is a really powerful meta-framework with a lot of features and huge ecosystem. Meanwhile, it's in RC2 right now so not 100% stable (may still work perfectly fine).
If your project is aiming for something simpler, I'd recommend using Vitesse. It may be a bit more stable and it's probably powerful enough (check what's coming with it to help you decide).
Some solutions like Prerender also exist but it's paid and not as good as some real SSG (/SSR). Also, it's more of a freemium.
I struggled with the same error output until I found the prerender-spa-plugin-next. Then I notice the latest version of prerender-spa-plugin was published 4 years ago and prerender-spa-plugin-next is continually updating. It seems like that prerender-spa-plugin-next is a new version of prerender-spa-plugin with the same functions. So I use prerender-spa-plugin-next instead of prerender-spa-plugin then everything works fine!
Here is my step:
install the package
npm i -D prerender-spa-plugin-next
modify vue.config.js like
const plugins = [];
if (process.env.NODE_ENV === 'production') {
const { join } = require('path');
const PrerenderPlugin = require('prerender-spa-plugin-next');
plugins.unshift(
new PrerenderPlugin({
staticDir: join(__dirname, 'dist'),
routes: ['/'], //the page route you want to prerender
})
);
}
module.exports = {
transpileDependencies: true,
configureWebpack(config) {
config.plugins = [...config.plugins, ...plugins];
},
};
build
npm run build
Then check the index.html under the dist folder you can see the page is prerendered.
Further usage refers to the homepage of prerender-spa-plugin-next
Found and fix about the scss files to import.
In nuxt.config.ts use :
vite: {
css: {
preprocessorOptions: {
scss: {
additionalData: `
#import "#/assets/scss/_variables.scss";
#import "#/assets/scss/my-style.scss";
`
}
},
},
}
Now my 2 mains issue are : how to install vuetify properly, currently syles and components seems working but the JS not, for example, accordions don't expands on click.
And second topic is to have a i18n module, it seems that vue-i18N no longer works.
Thanks.

Can't parse .mjs module from Iconify. Vue 3 cli using composition api and typescript

Update:
Changing: if(data.aliases?.[name2] !== void 0)
to: if(data.aliases != null && data.aliases[name2] !== void 0)
in the iconify .mjs file fixes the error, however this check occurs a lot of places, and is not viable. Any idea why I cant parse this type of null operator?
in ./node_modules/#iconify/vue/dist/iconify.mjs
Module parse failed: Unexpected token (99:21)You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
My code:
<template>
<div>
<Icon icon="mdi-light:home" />
</div>
</template>
<script setup lang="ts">
import { Icon } from "#iconify/vue";
</script>
Iconify version:
"#iconify/vue": "^3.2.0"
using standard vue cli babel:
presets: ["#vue/cli-plugin-babel/preset"]
I have tried: in babel.config.js
module.exports = function override(config) {
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto"
});
return config;
}
same error
I tried to remove the .mjs file, forcing it to use regular .js file, this resulted in same error but with missing .js loader.
I have tried to use Iconify SVG framework but i get the same type of error where loader is missing for .js files.
Thanks for any feedback :)
Solution:
Downgrading to this version of Iconify "#iconify/vue": "^3.1.1" fixed the problem. This resulted however in a error regarding type declaration. This was fixed by changing VS code's typescript version to: Use workspace version
This is done by selecting a .ts file then pressing "shift+ctrl+p" and select the prompt of select typescript version.
Having the same error cloning from the repository and install dependencies for Vue 2 https://github.com/iconify/iconify
Solution:
Downgrading to this version of Iconify "#iconify/vue": "^3.1.1" fixed the problem. This resulted however in a error regarding type declaration. This was fixed by changing VS code's typescript version to: Use workspace version
This is done by selecting a .ts file then pressing "shift+ctrl+p" and select the prompt of select typescript version.

Vue "These relative modules were not found" when using scss file

I'm trying to use a Bootstrap theme in my Vue application. Unfortunately the Bootstrap theme has no reference implementation for Vue. So I need to configure everything on my own.
What I want to do is, I want use the scss-files provided by the theme in Vue. So my App.vue component is pretty simple:
<template>
<div id="app">
</div>
</template>
<style lang="scss">
#import "#/assets/base.scss";
</style>
The "base.scss" file contains imports all dependencies. So, when I run my Vue application using "npm run serve", I get the following error:
ERROR Failed to compile with 10 errors
This dependency was not found:
-!../node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../node_modules/postcss-loader/src/index.js??ref--8-oneOf-1-2!typicons.font/src/font/typicons.css
in ./node_modules/cs
s-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist /cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=1&lang=scss&
To install it, you can run: npm install --save
-!../node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../node_modules/postcss-loader/src/index.js??ref--8-oneOf-1-2!typicons.fo
nt/src/font/typicons.css
These relative modules were not found:
./components/icons/linearicons/Linearicons-Free.eot in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/
sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=1&lang=scss&
./components/icons/linearicons/Linearicons-Free.eot?w118d in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_mo
dules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=1&lang=scss&
./components/icons/linearicons/Linearicons-Free.svg?w118d in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_mo
dules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=1&lang=scss&
./components/icons/linearicons/Linearicons-Free.ttf?w118d in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_mo
dules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=1&lang=scss&
./components/icons/linearicons/Linearicons-Free.woff2?w118d in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_
modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=1&lang=scss&
./components/icons/linearicons/Linearicons-Free.woff?w118d in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_m
odules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=1&lang=scss&
./components/slick-carousel/slick/ajax-loader.gif in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sa
ss-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=1&lang=scss&
./utils/images/logo-inverse.png in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs
.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=1&lang=scss&
./utils/images/logo.png in ./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref
--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=1&lang=scss&
Error from chokidar (C:): Error: EBUSY: resource busy or locked,
lstat 'C:\hiberfil.sys'
The referenced files are exist in the "#/assets/components/..." directory. But my problem is that I've no idea how I can set a relative path (e.g. "#/assets") searchs for the components. Furthermore there's no variable in the "base.scss" file I can adjust to set the relativ path. I also don't want modify the "base.scss" file because it comes from the theme.
I've no idea how to fix it this. I already tried to set the corresponding webpack-chain in vue.config.js without any success:
module.exports = {
chainWebpack: config => {
config.module
.rule('fonts')
.test(/\.(ttf|otf|eot|woff|woff2)$/)
.use('file-loader')
.loader('file-loader')
.tap(options => {
options = {
name: '#/assets/[path][name].[ext]'
}
return options
})
.end()
}
I hope anyone can help solving this problem :-)
I finally solved the issue by simply importing the "base.scss" in the "main.js" file and use it:
import theme from '#/assets/base.scss'
Vue.use(theme)

Rename img "src" dynamically in npm webpack

I am trying to create a module that will be used by other modules. However, this module contains html files.
Module 1 location c:/module_1
- Base HTML <img src="##__dirname/img/icon.png">
In module 1 he uses his icon.png.
In module 2, I would like it to use the icon.png of Module 2
I tried this:
plugins: [
new HtmlReplaceWebpackPlugin([
{
pattern: '##__dirname',
replacement: __dirname
},
...
html-replace-webpack-plugin
But compilation error occurs:
ERROR in Error: Child compilation failed:
Module not found: Error: Can't resolve './##_dirname/img/icon.png'
I noticed that it is possible to replace src after compiling
<img src="img/icon.png">
new HtmlReplaceWebpackPlugin([
{
pattern: /src=\"([^\"]*)\"/g,
replacement: function (match, $1)
{
return 'src="' + __dirname + '/src/img/' + $1 + '"';
}
}
]),
But I would like to replace before, and that when compiling it it takes the icon of the module in which it is being reused.
Is it possible to modify the img src dynamically in npm, even though it is a module that will be used as a dependency?
ps. I do not know much about the web and I do not know if I'm trying to do the project correctly. Just thought about reusing html code this way. If I'm doing something absurd, please let me know.
I solve the problem using React and this tutorial Setting Up a React.js Environment Using Npm, Babel 6 and Webpack

Gulp issue when copying over fonts

Every now and then, when I do a gulp build, I would get this error:
Error: EEXIST, mkdir 'Users/username/Desktop/Project/dist/fonts' at Error (native)
It doesn't happen on every build though. My gulp code to copy over fonts is:
gulp.src(paths.fonts { cwd: bases.app })
.pipe(flatten()) // using gulp-flatten
.pipe(gulp.dest(bases.dist + 'fonts/'));
Is there a way for me to fix this issue?
I believe you have to delete the old fonts/ folder first.
Use something like Gulp del:
I also like gulp-util for gulp console logs:
gulp.task('removeFonts', function(cb) {
del([bases.dist + 'fonts/'], cb);
gutil.log(gutil.colors.magenta('Fonts folder removed');
});
Then call your mkdir build.