How do I configure LESS with Aurelia ESnext Easy-Webpack? - less

I'm trying to configure Less CSS support in the Aurelia ESnext-Webpack Skeleton starter kit, and having pulled in a Less-based framework, I'm seeing the following warning when I run npm start:
WARNING in ./~/css-loader!./~/spectre.css/spectre.less
Module build failed: Unknown word (1:1)
> 1 | // Copyright 2016 Spectre.css
| ^
2 | // Licensed under MIT Open Source
3 |
4 | // Core variables
# ./src ^\.\/.*$
# ./~/aurelia-loader-webpack/dist/commonjs/aurelia-loader-webpack.js
# multi aurelia
Here's the configuration I'm using:
/* ./webpack.config.babel.js */
...
import html from '#easy-webpack/config-html'
import less from '#easy-webpack/config-less'
import css from '#easy-webpack/config-css'
...
let config = generateConfig(
...
html(),
less({ filename: 'styles.css', allChunks: true, sourceMap: false }),
css({ filename: 'styles.css', allChunks: true, sourceMap: false }),
...
)
...
However, despite the warning it appears to be working - styles.css contains all of the less assets when inspected in the browser.
Have I configured easy-webpack/config-less correctly?
If so, how do stop the warning message from showing?

Related

How can I use vue-monaco?

I'm trying to implement vue-monaco, but I get these errors:
ERROR Failed to compile with 2 errors 4:59:58 PM
error in ./node_modules/monaco-editor/esm/vs/basic-languages/_.contribution.js
Module parse failed: Unexpected token (37:13)
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
| return lazyLanguageLoaders[languageId];
| }
> _languageId;
| _loadingTriggered;
| _lazyLoadPromise;
# ./node_modules/monaco-editor/esm/vs/basic-languages/typescript/typescript.contribution.js 9:0-56 10:0-16
# include-loader!./node_modules/vue-monaco/node_modules/monaco-editor/esm/vs/editor/editor.main.js
# ./node_modules/vue-monaco/dist/vue-monaco.es.js
# ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/PlaygroundView.vue?vue&type=script&lang=js&
# ./src/views/PlaygroundView.vue?vue&type=script&lang=js&
# ./src/views/PlaygroundView.vue
# ./src/router/index.js
# ./src/main.js
# multi (webpack)-dev-server/client?http://X.X.X.X:8081&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
error in ./node_modules/monaco-editor/esm/vs/language/typescript/monaco.contribution.js
Module parse failed: Unexpected token (76:15)
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
| })(ModuleResolutionKind || {});
| var LanguageServiceDefaultsImpl = class {
> _onDidChange = new monaco_editor_core_exports.Emitter();
| _onDidExtraLibsChange = new monaco_editor_core_exports.Emitter();
| _extraLibs;
# include-loader!./node_modules/vue-monaco/node_modules/monaco-editor/esm/vs/editor/editor.main.js 101:0-92
# ./node_modules/vue-monaco/dist/vue-monaco.es.js
# ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/PlaygroundView.vue?vue&type=script&lang=js&
# ./src/views/PlaygroundView.vue?vue&type=script&lang=js&
# ./src/views/PlaygroundView.vue
# ./src/router/index.js
# ./src/main.js
# multi (webpack)-dev-server/client?http://X.X.X.X:8081&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
I think these issues are related to my vue.config.js; this is it:
const MonacoEditorPlugin = require('monaco-editor-webpack-plugin')
module.exports = {
transpileDependencies: [
'vuetify'
],
configureWebpack: {
plugins: [
new MonacoEditorPlugin({
languages: ['javascript', 'typescript']
})
],
},
}
Component implementation is almost identical to the guide. The guide seems pretty straightforward, so what am I doing wrong?
P.S. I even tried monaco-editor-vue, but I got almost the same errors.
To make it work I had to downgrade monaco-editor-webpack-plugin to 1.9.1; related link here. Note that typescript language is also needed, even though you want only javascript; related link here.

How to fix Unexpected token error while compiling vuejs project?

Following these steps:
Install fresh vuejs 2. Don't change package.json.
Install vue-notion package. This is a renderer for the Notion based on vuejs.
Inject the NotionRenderer object into any page like in an official example: import { NotionRenderer } from 'vue-notion'
Run npm run serve or yarn serve (I've tried both)
... I get the following error while compiling:
error in ./node_modules/vue-notion/dist/esm.js
Module parse failed: Unexpected token (1793:175)
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
|
| // return empty notion decorated text if row is empty
> return (this === null || this === void 0 ? void 0 : (_this$properties = this.properties) === null || _this$properties === void 0 ? void 0 : _this$properties[columnId]) ?? [[" ", false]];
| },
|
# ./src/main.js 9:0-44
# multi (webpack)-dev-server/client?http://192.168.0.107:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
The problem is the nullish coalescing operator (??) at the end of the string.
I've tried to add #babel/plugin-proposal-nullish-coalescing-operator into babel.config, but it still doesn't work:
module.exports = {
presets: [
'#vue/cli-plugin-babel/preset'
],
plugins: [
'#babel/plugin-proposal-nullish-coalescing-operator',
],
}
How can I fix it? What kind of a loader should I use to compile the code?
Thank #Jonathan. I've solved this problem by adding a transpile directive into vue.config.js:
module.exports = {
transpileDependencies: ["vue-notion"]
}

Error when adding highchartsjs to Vue3 app

I am using Vue 3 and added highchartsjs according to the docs. I am getting this error:
✘ [ERROR] Could not resolve "highcharts"
node_modules/highcharts-vue/dist/highcharts-vue.min.js:1:90:
1 │ ...?module.exports=e(require("highcharts"),require("vue")):"functio...
╵ ~~~~~~~~~~~~
You can mark the path "highcharts" as external to exclude it from the bundle,
which will remove this error. You can also surround this "require" call with a
try/catch block to handle this failure at run-time instead of bundle-time.
I tried excluding it from bundle as suggested but it's not working:
vite.config.js
export default defineConfig({
...
build: {
rollupOptions: {
external: ['highcharts'],
}
},
})
This works:
export default defineConfig({
...
optimizeDeps: {
exclude: ['highcharts'],
}
})
Excluding highcharts via optimizeDeps.exclude would clear the error, but that would defeat your ultimate goal of using highcharts in your project. You'll notice that after using that config, your project still is not able to import highcharts. The error is indicating that your project is missing that dependency.
The solution would be to install highcharts:
npm install -S highcharts
demo

Expo Auth Session breaking Jest tests | Jest encountered an unexpected token

I'm building an Expo app with jest as my test runner.
After incorporateing expo-auth-session into the project, I get the following error:
FAIL screens/tests/EntriesScreen.test.jsx
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/en/ecmascript-modules for how to enable it.
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
C:\Users\User\repos\BROG-Trip-Journal\node_modules\expo-auth-session\providers\google.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export * from '../build/providers/Google';
^^^^^^
SyntaxError: Unexpected token 'export'
17 | Alert,
18 | } from 'react-native';
> 19 | import * as Google from 'expo-auth-session/providers/google';
| ^
20 | import { useDispatch } from 'react-redux';
21 | import { FontAwesomeIcon } from '#fortawesome/react-native-fontawesome';
22 | import PropTypes from 'prop-types';
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
at Object.<anonymous> (screens/AuthScreen.jsx:19:1)
I'm no stranger to this error on this project. In the past, all I had to do was add the offending module to the transformIngnorePattern so that it would get transpiled by bable. But this time, it's not working.
Here is what my jest.config.js looks like right now:
module.exports = {
preset: 'jest-expo',
moduleDirectories: ['node_modules', 'test-utils'],
setupFiles: ['./node_modules/react-native-gesture-handler/jestSetup.js'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
},
transformIgnorePatterns: [
'/node_modules/(?!(#react-native|react-native|#fortawesome|expo-app-loading|expo-splash-screen|expo-modules-core|expo-font|expo-asset|expo-constants|expo-sqlite|#react-navigation|expo-location|#expo|expo-status-bar|react-native-keyboard-aware-scroll-view|react-native-iphone-x-helper|expo-auth-session)/).*/',
],
setupFilesAfterEnv: [
'#testing-library/jest-native/extend-expect',
'./jest.setup.js',
],
};
What am I missing?

Error after added Nuxt to my vue project (vue-style-loader css error)

Help me please. Added Nuxt(SSR) to the my vue project. All moved to the root of the project, created a page folder. The following error appeared:
ERROR in ./.nuxt/components/nuxt-loading.vue?vue&type=style&index=0&lang=css& (./node_modules/css-loader/dist/cjs.js??ref--3-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--3-oneOf-1-2!./node_modules/vue-loader/lib??vue-loader-options!./.nuxt/components/nuxt-loading.vue?vue&type=style&index=0&lang=css&)
Module build failed (from ./node_modules/css-loader/dist/cjs.js):
ValidationError: Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
- options.modules has an unknown property 'compileType'. These properties are valid:
object { auto?, mode?, exportGlobals?, localIdentName?, localIdentRegExp?, context?, hashPrefix?, getLocalIdent? }
at validate (/app/node_modules/css-loader/node_modules/schema-utils/dist/validate.js:98:11)
at Object.loader (/app/node_modules/css-loader/dist/index.js:36:28)
# ./.nuxt/components/nuxt-loading.vue?vue&type=style&index=0&lang=css& (./node_modules/vue-style-loader??ref--3-oneOf-1-0!./node_modules/css-loader/dist/cjs.js??ref--3-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--3-oneOf-1-2!./node_modules/vue-loader/lib??vue-loader-options!./.nuxt/components/nuxt-loading.vue?vue&type=style&index=0&lang=css&) 4:14-327
# ./.nuxt/components/nuxt-loading.vue?vue&type=style&index=0&lang=css&
# ./.nuxt/components/nuxt-loading.vue
# ./.nuxt/App.js
# ./.nuxt/index.js
# ./.nuxt/client.js
# multi ./.nuxt/client.js
code from nuxt.config.js:
import { resolve } from 'path'
export default {
alias: {
style: resolve(__dirname, './assets/style'),
},
}
As I understand the error is related to the setting of the Nuxt.
In your package.json you do have sass-loader set to ^12.1.0, meanwhile the package introduces a breaking change during v11.0.0.
It requires Webpack5, which Nuxt is not compatible as of today. If you downgrade it down to v10.1.1 (and all related packages like node-sass), you should be fine.