Nuxt hot reloading somehow works for old components, but any new components that I have created today, doesn't seem to be watched by the app, and doesn't reload. I have to restart the app each time to see the changes applied to these new files.
The machine that I am using is MacOs latest Mojave system.
I realized people might ask for the package.json file so here is the file
{
"name": "theta",
"version": "1.0.0",
"description": "My fabulous Nuxt.js project",
"private": true,
"scripts": {
"dev": "NUXT_HOST=0.0.0.0 NUXT_PORT=3333 nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"devHttps": "node server/index.js"
},
"dependencies": {
"#clampy-js/vue-clampy": "^1.0.6",
"#fortawesome/free-brands-svg-icons": "^5.9.0",
"#fortawesome/free-solid-svg-icons": "^5.9.0",
"#nuxtjs/auth": "^4.7.0",
"#nuxtjs/axios": "^5.5.4",
"#nuxtjs/component-cache": "^1.1.5",
"#nuxtjs/dotenv": "^1.3.0",
"#nuxtjs/google-adsense": "^1.1.3",
"#nuxtjs/google-analytics": "^2.2.0",
"#nuxtjs/moment": "^1.2.0",
"#nuxtjs/pwa": "^2.6.0",
"#nuxtjs/robots": "^2.2.0",
"#nuxtjs/style-resources": "^0.1.2",
"#nuxtjs/svg-sprite": "^0.2.1",
"#nuxtjs/toast": "^3.2.1",
"#nuxtjs/vuetify": "^0.5.6",
"#sum.cumo/nuxt-styleguide": "^5.3.0",
"atob": "^2.1.2",
"axios": "^0.19.0",
"browserslist": "^4.6.2",
"caniuse-lite": "^1.0.30000974",
"chart.js": "^2.8.0",
"cookie": "^0.3.1",
"cookie-parser": "^1.4.4",
"cookie-universal-nuxt": "^2.0.16",
"cross-env": "^5.2.0",
"echarts": "^4.2.1",
"element-ui": "^2.9.1",
"epic-spinners": "^1.1.0",
"fstream": "^1.0.12",
"imagemagick": "^0.1.3",
"intersection-observer": "^0.5.1",
"js-yaml": "^3.13.1",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.11",
"lodash-es": "^4.17.11",
"moment": "^2.24.0",
"nuxt": "^2.8.1",
"nuxt-compress": "^1.0.2",
"nuxt-device-detect": "^1.1.5",
"nuxt-fontawesome": "^0.4.0",
"nuxt-stripe-module": "^2.0.0",
"nuxt-universal-storage": "^0.2.0",
"nuxt-validate": "^0.1.3",
"nuxt-webfontloader": "^1.1.0",
"swiper": "^4.5.0",
"tar": "^4.4.10",
"tb-skeleton": "^0.3.6",
"uuid": "^3.3.2",
"v-charts": "^1.19.0",
"v-click-outside-x": "^3.7.1",
"vee-validate": "^2.2.10",
"vue": "^2.6.10",
"vue-avatar-editor-improved": "^1.0.4",
"vue-awesome-swiper": "^3.1.3",
"vue-chartjs": "^3.4.2",
"vue-clamp": "^0.2.1",
"vue-count-to": "^1.0.13",
"vue-croppa": "^1.3.8",
"vue-infinite-loading": "^2.4.4",
"vue-line-clamp": "^1.3.2",
"vue-loaders": "^2.0.0",
"vue-match-media": "^1.0.3",
"vue-scrollama": "^1.1.1",
"vue-scroller": "^2.2.4",
"vue-scrollto": "^2.15.0",
"vue-server-renderer": "^2.6.10",
"vue-swipe-tab": "^2.0.4",
"vue-template-compiler": "^2.6.10",
"vue-text-dot": "^1.0.0",
"vue-the-mask": "^0.11.1",
"vue-tiny-lazyload-img": "^0.1.0",
"vue-truncate-collapsed": "^2.1.0",
"vue-zondicons": "^0.1.10",
"vue2-datepicker": "^2.11.2",
"vue2-editor": "^2.8.1",
"vue2-touch-events": "^1.1.2",
"vuetify-loader": "^1.2.2",
"vuetify-upload-button": "^1.2.2",
"vuex-router-sync": "^5.0.0"
},
"devDependencies": {
"autoprefixer": "^9.6.0",
"css-loader": "^2.1.1",
"moment-locales-webpack-plugin": "^1.0.7",
"node-sass": "^4.12.0",
"nodemon": "^1.19.1",
"postcss-gap-properties": "^2.0.0",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2"
}
}
Here is my nuxt config file
const pkg = require('./package')
const webpack = require('webpack')
require('dotenv').config()
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: 'ノーブル',
meta: [{
charset: 'utf-8'
},
{
name: 'viewport',
content: 'width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1'
},
{
hid: 'description',
name: 'description',
content: '小説家・読者のプラットフォーム'
}
],
link: [{
rel: 'icon',
type: 'image/x-icon',
href: '/favicon.ico'
}],
script: [{
src: '/js/fb-sdk.js'
}, {
src: '/js/gg-sdk.js'
}]
},
/*
** Customize the progress-bar color
*/
loading: {
color: '#af9bd0',
height: '3px',
continuous: true
},
generate: {
routes: [
'/ads.txt',
]
},
/*
** Global CSS
*/
css: [
'element-ui/lib/theme-chalk/index.css',
'swiper/dist/css/swiper.css',
"assets/css/index.css",
"assets/css/main.scss",
'vue-loaders/dist/vue-loaders.css'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
'#/plugins/element-ui',
'#/plugins/intercept',
{
src: '~plugins/vue-star-rating',
ssr: false
},
{
src: '~/plugins/swiper',
ssr: false
},
{
src: '~/plugins/intercept',
ssr: false
},
{
ssr: false,
src: '~/plugins/avatar'
},
{
ssr: false,
src: "~plugins/clickOutside"
}, {
ssr: false,
src: "~plugins/vueEditor"
}, {
src: '#/plugins/vueMask',
ssr: false
}, {
src: '#/plugins/zondiIcon',
ssr: false
}, {
src: '#/plugins/elementLoading',
ssr: false
}, {
src: '#/plugins/vue-swipe-tab',
ssr: false
},
{
src: '#/plugins/pull-to',
ssr: false
},
{
src: '#/plugins/datePicker',
ssr: false
}, {
src: '#/plugins/vuelineclamp',
ssr: false
}, {
src: '#/plugins/graphs',
ssr: false
}, {
src: '#/plugins/infinite',
ssr: false
}, {
src: '#/plugins/vueClamp',
ssr: false
}, {
src: '#/plugins/watchMedia',
ssr: false
}, {
src: '#/plugins/scrollama',
ssr: false
}, {
src: '#/plugins/countTo',
ssr: false
}, {
src: '#/plugins/chartLine',
ssr: false
}, {
src: '#/plugins/skeleton',
ssr: false
}, {
src: '#/plugins/gAuth',
ssr: false,
}, {
src: '#/plugins/epicSpinners',
ssr: false,
},
{
src: '#/plugins/auth',
}
],
/*
** Nuxt.js modules
*/
modules: [
['#nuxtjs/vuetify', {
treeShake: true
}],
'#nuxtjs/pwa',
'nuxt-device-detect',
'nuxt-webfontloader',
'#nuxtjs/axios',
'#nuxtjs/dotenv',
'#nuxtjs/svg-sprite',
'#nuxtjs/style-resources',
['nuxt-validate', {
lang: 'ja',
}],
['#nuxtjs/robots', {
UserAgent: '*',
Disallow: '/',
UserAgent: 'Googlebot',
Disallow: '',
UserAgent: 'Yahoo-slurp',
Disallow: '',
UserAgent: 'Msnbot',
Disallow: ''
}],
['#nuxtjs/moment', {
locales: ['ja'],
defaultLocale: 'ja'
}],
['#nuxtjs/component-cache', {
maxAge: 1000 * 60 * 60
}],
['#nuxtjs/google-adsense', {
id: 'pub-4438410171989811'
}],
'cookie-universal-nuxt',
['nuxt-fontawesome', {
component: 'fa',
imports: [{
set: '#fortawesome/free-solid-svg-icons',
icons: ['fas']
}, {
set: '#fortawesome/free-brands-svg-icons',
icons: ['fab']
}]
}],
['#nuxtjs/google-analytics', {
id: 'UA-119733183-2',
autoTracking: {
page: false
}
}],
['nuxt-universal-storage', {
storage: {
vuex: true, // boolean or {namespace}
localStorage: true, // boolean or {prefix }
cookie: true, // boolean or {prefix, options }
initialState: {}, // Object {}
ignoreExceptions: true //
}
}],
['#nuxtjs/dotenv', {
/* module options */
}],
['#nuxtjs/toast', {
position: 'top-right',
duration: 5000
}],
['nuxt-stripe-module', {
publishableKey: process.env.STRIPE_KEY,
version: 'v3', // Default
}],
"nuxt-compress",
],
/*
** Axios module configuration
*/
axios: {
baseURL: process.env.SERVER_URL || 'http://0.0.0.0:5000/api',
credentials: false,
proxyHeaders: false
},
auth: {
strategies: {
google: {
client_id: process.env.GOOGLE_CLIENT_ID,
user: false,
redirect_uri: 'http://127.0.0.1:3000/'
},
facebook: {
client_id: process.env.FACEBOOK_CLIENT_ID,
userinfo_endpoint: false,
scope: ['public_profile', 'email'],
redirect_uri: 'https://tolocalhost.com/'
},
local: {
_scheme: '~/auth/local.js',
endpoints: {
login: {
url: 'auth/login',
method: 'post',
propertyName: false
},
user: {
url: 'user/show',
method: 'get',
propertyName: false
},
logout: false
}
}
},
redirect: {
login: '/auth/login',
logout: '/',
callback: '/',
home: '/'
},
plugins: ['~/plugins/auth.js']
},
router: {
middleware: ['auth'],
linkActiveClass: 'active-link'
},
webfontloader: {
google: {
families: ['IBM Plex Sans:300,400,700', 'Noto Sans JP:400,500', 'Sniglet:400,800'] //Loads Lato font with weights 400 and 700
}
},
'manifest': {
name: 'ノーブル 小説',
short_name: 'ノーブル',
lang: 'ja'
},
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
*/
extend(config, ctx) {
},
splitChunks: {
layouts: true
},
styleResources: {
sass: ['./assets/css/abstracts/main.scss']
},
transpile: ['vue-clamp', 'resize-detector'],
postcss: {
plugins: [
require('postcss-gap-properties')(),
require('autoprefixer')({
grid: true,
flexbox: true,
stats: {
warnings: false
}
})
]
},
plugins: [new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
})]
},
server: {
port: process.env.CLIENT_PORT || 4000, // default: 3000
host: process.env.API_HOST || '0.0.0.0', // default: localhost
},
}
I've searched everywhere online for the answer but none that seemed close to my current situation.
Oh I got it, it seems like there was a misspelling in importing of the component, and thus wasn't connected to the main nuxt network, meaning the component doesn't adhere to the hot reloading watched file.
Had the problem of hot reload not working.
Solved that by adding
watchers: {
webpack: {
aggregateTimeout: 300,
poll: 1000
}
}
in the nuxt.config.js file.
Related
I tried use vite to build my project. I used package version is
"vue": "2.7.13",
"vite": "^3.2.2",
devDependencies
"devDependencies": {
"#originjs/vite-plugin-commonjs": "^1.0.3",
"#originjs/vite-plugin-require-context": "^1.0.9",
"autoprefixer": "^9.8.8",
"chalk": "2.4.2",
"connect": "3.6.6",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.7.0",
"mockjs": "1.0.1-beta3",
"postcss": "^8.4.18",
"prettier": "^2.7.1",
"rollup-plugin-external-globals": "^0.6.1",
"runjs": "^4.3.2",
"sass": "^1.55.0",
"script-loader": "0.7.2",
"serve-static": "^1.13.2",
"svgo": "1.2.2",
"vite": "^3.2.2",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-html": "^3.2.0",
"vite-plugin-require-transform": "^1.0.4",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-vue2": "^2.0.2",
"vue-template-compiler": "2.7.13"
},
vite.config.js
import path from 'path'
import { defineConfig, loadEnv } from 'vite'
import { createVuePlugin } from 'vite-plugin-vue2'
import requireTransform from 'vite-plugin-require-transform'
import ViteRequireContext from '#originjs/vite-plugin-require-context'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { createHtmlPlugin } from 'vite-plugin-html'
import eslintPlugin from 'vite-plugin-eslint'
import externalGlobals from 'rollup-plugin-external-globals'
import { viteCommonjs } from '#originjs/vite-plugin-commonjs'
export default ({mode}) => {
const env = loadEnv(mode, process.cwd())
return defineConfig({
define: {
'process.env': { ...env }
},
plugins: [
viteCommonjs(),
createVuePlugin(),
requireTransform({
fileRegex: /.js$|.jsx$|.vue$/
}),
ViteRequireContext(),
eslintPlugin(),
createHtmlPlugin({
minify: true
}),
createSvgIconsPlugin({
iconDirs: [path.resolve(__dirname, './src/icons/svg')],
symbolId: 'icon-[name]',
inject: 'body-last' | 'body-first',
customDomId: '__svg__icons__dom__'
})
],
resolve: {
alias: [
{
find: '#',
replacement: path.resolve(__dirname, 'src')
},
{
find: /^~(.*)$/,
replacement: '$1'
}
],
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
build: {
target: 'es2015',
cssTarget: 'chrome61',
brotliSize: false,
chunkSizeWarningLimit: 2000,
sourcemap: true,
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
rollupOptions: {
plugins: [
externalGlobals({
vue: 'Vue',
'element-ui': 'ELEMENT',
vuex: 'Vuex',
lodash: '_',
'$': 'jquery',
axios: 'axios',
'vue-router': 'Router',
})
],
external: ['element-ui', 'vue', 'vuex', 'axios', 'lodash', 'vue-router', 'jquery'],
output: {
entryFileNames: `assets/js/entry[hash].js`,
chunkFileNames: `assets/js/chunk[hash].js`,
assetFileNames: `assets/files/[hash][extname]`,
},
}
},
})
}
I run build, it's work.
# vite build
$ npm run build
But I run preview, I get this error message
Uncaught ReferenceError: Vue is not defined
How could I fix it? Thanks your help.
Imported a Nuxt project from GitHub with vercel.json config:
{
"version": 2,
"builds": [
{
"src": "nuxt.config.js",
"use": "#nuxtjs/vercel-builder"
}
]
}
My package.json:
{
"name": "test-app-v2",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint": "yarn lint:js"
},
"lint-staged": {
"*.{js,vue}": "eslint"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"dependencies": {
"#nuxtjs/composition-api": "^0.24.0",
"#nuxtjs/pwa": "^3.3.5",
"core-js": "^3.9.1",
"nuxt": "^2.15.3"
},
"devDependencies": {
"#nuxt/types": "^2.15.3",
"#nuxt/typescript-build": "^2.1.0",
"#nuxtjs/eslint-config-typescript": "^6.0.0",
"#nuxtjs/eslint-module": "^3.0.2",
"#nuxtjs/vuetify": "^1.11.3",
"babel-eslint": "^10.1.0",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-nuxt": "^2.0.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^7.7.0",
"husky": "^4.3.8",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1"
}
}
and nuxt.config.js
import colors from 'vuetify/es5/util/colors'
export default {
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
titleTemplate: '%s - test-app-v2',
title: 'test-app-v2',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/typescript
'#nuxt/typescript-build',
// https://go.nuxtjs.dev/vuetify
'#nuxtjs/vuetify',
'#nuxtjs/composition-api/module',
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/pwa
'#nuxtjs/pwa',
],
// PWA module configuration: https://go.nuxtjs.dev/pwa
pwa: {
manifest: {
lang: 'en',
},
},
// Vuetify module configuration: https://go.nuxtjs.dev/config-vuetify
vuetify: {
customVariables: ['~/assets/variables.scss'],
theme: {
dark: false,
themes: {
dark: {
primary: colors.blue.darken2,
accent: colors.grey.darken3,
secondary: colors.amber.darken3,
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3,
},
},
},
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {},
}
I have no API yet and this is the error log in function tab:
Wasn't the OPs aim to deploy it using SSR? Using build command yarn generate will just generate a static site.
EDIT: updating the build command fixed OP's issue.
Do you even need the vercel.json here?
I've tried to host one of my repo there and it's working fine with those settings only.
Hosted there: https://nuxt-tailwind-typography-darkmode-boilerplate.vercel.app/
Vercel pretty much self-detected that it was a Nuxt project and almost aced it itself.
I'm using Nuxt 2.15.4 and nuxt/vuetify 1.11.3
my project was working fine, but when i move it to a new server at build I got these errors:
this is my package.json file
{
"name": "myproject",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"#nuxtjs/auth": "^4.9.1",
"#nuxtjs/axios": "^5.13.1",
"#nuxtjs/device": "^2.1.0",
"#nuxtjs/google-gtag": "^1.0.4",
"#nuxtjs/gtm": "^2.4.0",
"chart.js": "^2.9.3",
"cookie-universal-nuxt": "^2.1.4",
"core-js": "^3.9.1",
"jquery": "^3.5.1",
"nuxt": "^2.15.3",
"swiper": "^5.4.5",
"v-viewer": "^1.5.1",
"vee-validate": "^3.3.7",
"vue-awesome-swiper": "^4.1.1",
"vue-chartjs": "^3.5.0",
"vue-cropperjs": "^4.1.0",
"vue-easy-dnd": "^1.10.2",
"vue-glide-js": "^1.3.14",
"vue-persian-datetime-picker": "^2.2.0",
"vue-product-zoomer": "^3.0.1",
"vue-slick-carousel": "^1.0.6",
"vue-sweetalert2": "^4.2.1",
"vue2-editor": "^2.10.2",
"vuedraggable": "^2.24.0"
},
"devDependencies": {
"#fortawesome/fontawesome-free": "^5.15.1",
"#mdi/font": "^5.9.55",
"#nuxtjs/dotenv": "^1.4.1",
"#nuxtjs/vuetify": "1.11.3",
"flipclock": "^0.10.8",
"font-awesome": "^4.7.0",
"noty": "^3.2.0-beta",
"nuxt-gsap-module": "^1.2.1",
"css-loader": "^5.0.0",
"sass-loader": "^10.1.1",
"less-loader": "^6.1.2"
}
}
and my nuxt.config
import colors from 'vuetify/es5/util/colors'
const env = require('dotenv').config()
const webpack = require('webpack')
export default {
telemetry: false,
loading: {
color: 'green',
failedColor: 'red',
height: '3px'
},
// serverMiddleware: ['~/api/index.js'],
router: {
// base: process.env.NUXT_BASE_URL || '/'
},
/*
** Headers of the page
** See https://nuxtjs.org/api/configuration-head
*/
head: {
// titleTemplate: '%s - ' + process.env.npm_package_name,
// title: process.env.npm_package_name || '',
// titleTemplate: '%s - ' + process.env.SITE_TITLE,
title: process.env.SITE_TITLE + ' | ' + process.env.SITE_SHORT_DESC || '',
htmlAttrs: {
lang: process.env.SITE_LANGUAGE || 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'keywords', name: 'keywords', content: process.env.SITE_KEYWORDS || '' },
{ hid: 'description', name: 'description', content: process.env.SITE_DESCRIPTION || '' },
{ hid: 'robots', name: 'robots', content: process.env.SITE_ROBOTS || '' },
{ hid: 'googlebot', name: 'googlebot', content: process.env.SITE_GOOGLE_BOT || '' },
{ hid: 'bingbot', name: 'bingbot', content: process.env.SITE_BING_BOT || '' },
{ hid: 'og:locale', name: 'og:locale', content: process.env.SITE_OG_LOCALE || '' },
{ hid: 'og:type', name: 'og:type', content: process.env.SITE_OG_TYPE || '' },
{ hid: 'og:title', name: 'og:title', content: process.env.SITE_OG_TITLE || '' },
{ hid: 'og:description', name: 'og:description', content: process.env.SITE_OG_DESCRIPTION || '' },
{ hid: 'og:url', name: 'og:url', content: process.env.SITE_BASE_URL || '' },
{ hid: 'og:site_name', name: 'og:site_name', content: process.env.SITE_OG_SITENAME || '' },
{ hid: 'theme-color', name: 'theme-color', content: process.env.SITE_THEME_COLOR || '' },
{ hid: 'msapplication-navbutton-color', name: 'msapplication-navbutton-color', content: process.env.SITE_MSAPP_NAVBTN_COLOR || '' },
{ hid: 'apple-mobile-web-app-status-bar-style', name: 'apple-mobile-web-app-status-bar-style', content: process.env.SITE_APPLE_WM_STATUSBAR_STYLE || '' },
{ hid: 'X-UA-Compatible', 'http-equiv': 'X-UA-Compatible', content: process.env.SITE_X_UA_Compatible || '' },
{ hid: 'google-site-verification', name:'google-site-verification', content: 'T_NpyOb-VoAjaAcnhB8b9MTslHVfhtfcLNf2dvBtlfI' },
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: process.env.SITE_FAVICON },
// { rel: 'shortcut icon', type: 'image/x-icon', href: process.env.SITE_FAVICON },
{ rel: 'canonical', href: process.env.SITE_BASE_URL },
// { rel: 'stylesheet', href: 'https://cdn.jsdelivr.net/npm/font-awesome#4.x/css/font-awesome.min.css' },
]
},
/*
** Global CSS
*/
css: [
'~/assets/scss/vuetify.scss',
'~/assets/scss/style.scss',
'#mdi/font/css/materialdesignicons.css',
'font-awesome/css/font-awesome.min.css',
'#fortawesome/fontawesome-free/css/all.css',
'~/assets/scss/media.scss',
'~/assets/scss/customization.scss',
'~/assets/scss/sweetalert.scss',
'~/assets/scss/noty.scss',
'~/assets/scss/flipclock.scss',
'~/assets/scss/glide.scss',
'~/assets/scss/sorting.scss',
'~/assets/scss/cropper.scss',
'~/assets/scss/transitions.scss',
'~/assets/scss/product-zoom.scss',
'vue-slick-carousel/dist/vue-slick-carousel.css',
'swiper/css/swiper.css',
],
/*
** Plugins to load before mounting the App
** https://nuxtjs.org/guide/plugins
*/
plugins: [
'plugins/mixins/reqerrors.js',
'plugins/mixins/user.js',
'plugins/mixins/language.js',
'plugins/mixins/shopinfo.js',
'plugins/mixins/formattedprice.js',
'plugins/mixins/utils.js',
'plugins/mixins/cms.js',
'plugins/mixins/client.js',
'plugins/mixins/cart.js',
'plugins/axios.js',
'plugins/veevalidate.js',
'plugins/noty.js',
'plugins/glide.js',
'#plugins/vuedraggable',
'#plugins/vuedraggable',
'#plugins/vue-slick-carousel.js',
{src: 'plugins/vuepersiandatepicker.js', mode: 'client'},
{src: 'plugins/cropper.js', mode: 'client'},
{src: 'plugins/vue-product-zoomer.js', mode: 'client'},
{src: 'plugins/vueeditor.js', mode: 'client'},
{src: 'plugins/nuxt-swiper-plugin.js', mode: 'client' }
],
// Auto import components: https://go.nuxtjs.dev/config-components
// components: true,
/*
** Nuxt.js dev-modules
*/
buildModules: [
'#nuxtjs/dotenv',
'#nuxtjs/vuetify',
'#nuxtjs/device',
'nuxt-gsap-module',
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
'#nuxtjs/axios',
// Doc: https://auth.nuxtjs.org/guide/
'#nuxtjs/auth',
// Doc: https://sweetalert2.github.io/
['vue-sweetalert2/nuxt',
{
confirmButtonColor: '#29BF12',
cancelButtonColor: '#FF3333'
}
],
'cookie-universal-nuxt',
'#nuxtjs/gtm',
'#nuxtjs/google-gtag',
],
device: {
// defaultUserAgent: 'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.39 Mobile Safari/537.36',
refreshOnResize: true
},
gtm: {
id: process.env.GOOGLE_TAGS_ID,
// enabled: undefined, /* see https://github.com/nuxt-community/gtm-module */
debug: false,
// layer: 'dataLayer',
// variables: {},
// pageTracking: false,
// pageViewEventName: 'nuxtRoute',
// autoInit: true,
// respectDoNotTrack: true,
// scriptId: 'gtm-script',
// scriptDefer: false,
// scriptURL: 'https://www.googletagmanager.com/gtm.js',
// crossOrigin: false,
// noscript: true,
// noscriptId: 'gtm-noscript',
// noscriptURL: 'https://www.googletagmanager.com/ns.html'
},
'google-gtag': {
id: process.env.GOOGLE_ANALYTICS_ID,
// config: {
// anonymize_ip: true, // anonymize IP
// send_page_view: false, // might be necessary to avoid duplicated page track on page reload
// linker: {
// domains: ['domain.com','domain.org']
// }
// },
debug: false, // enable to track in dev mode
// disableAutoPageTrack: false, // disable if you don't want to track each page route with router.afterEach(...).
// additionalAccounts: [{
// id: 'AW-XXXX-XX', // required if you are adding additional accounts
// config: {
// send_page_view: false // optional configurations
// }
// }]
},
dotenv: {
/* module options */
},
gsap: {
extraPlugins: {
cssRule: false,
draggable: false,
easel: false,
motionPath: false,
pixi: false,
text: false,
scrollTo: false,
scrollTrigger: false
},
extraEases: {
expoScaleEase: false,
roughEase: false,
slowMo: true,
}
},
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {
baseURL: process.env.API_BASE_URL,
},
/*
** Auth module configuration
** See https://auth.nuxtjs.org/options
*/
auth: {
strategies: {
local: {
endpoints: {
login: { url: 'auth/login', method: 'post', propertyName: 'token' },
logout: { url: 'auth/logout', method: 'post' },
user: { url: 'auth/info', method: 'get', propertyName: '' }
}
}
},
redirect: {
login: '/login',
// callback: '/login',
home: '',
logout: '/login'
},
cookie: {
prefix: 'auth.',
options: {
path: '/',
maxAge: process.env.AUTH_COOKIE_MAX_AGE
}
}
},
publicRuntimeConfig: {
gtm: {
id: process.env.GOOGLE_TAGS_ID
},
'google-gtag': {
id: process.env.GOOGLE_ANALYTICS_ID,
}
},
vuetify:{
rtl: process.env.SITE_DIRECTION === 'rtl' ? true : false ,
customVariables: ['~/assets/scss/stylevariables.scss'],
icons: {
iconfont: 'mdi',
},
treeShake: true,
theme: {
dark: false,
themes: {
dark: {
primary: colors.blue.darken2,
accent: colors.grey.darken3,
secondary: colors.amber.darken3,
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3
}
}
}
},
/*
** Build configuration
** See https://nuxtjs.org/api/configuration-build/
*/
build: {
transpile: ['vee-validate/dist/rules'],
plugins: [
new webpack.ProvidePlugin({
'$': 'jquery',
jQuery: "jquery",
"window.jQuery": "jquery",
'_': 'lodash'
}),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
],
// postcss: {
// preset: {
// features: {
// customProperties: false,
// },
// },
// },
loaders: {
scss: {
additionalData: `
$theme_body_color:${process.env.THEME_BODY_COLOR};
$theme_main_color:${process.env.THEME_MAIN_COLOR};
$theme_main_color2:${process.env.THEME_MAIN_COLOR2};
$theme_side_color:${process.env.THEME_SIDE_COLOR};
$theme_side_color2:${process.env.THEME_SIDE_COLOR2};
$theme_link_color:${process.env.THEME_LINK_COLOR};
`
}
},
}
}
even when the new server got error, my localhost was working fine. then i deleted node_modules and package-lock.json and used npm i ; now my localhost is also has these errors
does anyone know what has caused the problem??
Installing npm install sass#1.32.8 fixes the issue for the time being. If you're using nuxt + yarn you might have to set this through the resolutions property in package.json, but in general this is the recommend solution: https://github.com/sass/dart-sass/issues/1287
The underlying cause is new versions of sass somehow taking issue with lines containing only whitespace.
In my case I also had to leave out the "^", otherwise npm install downloads version "1.32.10".
"sass": "1.32.8",
I get same error. & I changed sass-loader & less-loader dependencies to under versions. & add sass dependancy
In my package.json
"less": "^4.1.1",
"less-loader": "^2.0.0",
"sass": "1.32.8",
"sass-loader": "10.1.1",
had the same issue starting 2 days ago, tried going back a few versions on both Nuxtjs and Vuetify but nothing worked
Disabling treeshake did it for me, I hope this is temporary.
Thanks for the info.
Looks like it was caused by treeShake option in vuetify, so by removing it (or false) , every thing went back to normal.
*** UPDATE ***
Removing treeShake only works on dev and still gives error in npm run build. But treeShake: false works fine on both dev and build
// nuxt.config.js
vuetify:{
rtl: process.env.SITE_DIRECTION === 'rtl' ? true : false ,
customVariables: ['~/assets/scss/stylevariables.scss'],
icons: {
iconfont: 'mdi',
},
treeShake: false,
theme: {
dark: false,
themes: {
dark: {
primary: colors.blue.darken2,
accent: colors.grey.darken3,
secondary: colors.amber.darken3,
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3
}
}
}
},
Update
finally turned on my treeShake and surprisingly work with "sass": "1.32.13" , "nuxt": "2.15.4", "#nuxtjs/vuetify": "1.11.3"
useing vue-cli4
Using UglifyJsPlugin then leads to a series of problems because I want to compress the package size of the component to optimize the server response
Babel. Config. Js es2015 has been replaced # Babel/preset - env I did the following configuration
There is still a syntax validation problem
package.json
"dependencies": {
"#babel/preset-react": "^7.9.4",
"#babel/preset-stage-3": "^7.8.3",
"babel": "^6.23.0",
"babel-plugin-transform-runtime": "^7.0.0-beta.3",
"babel-polyfill": "^6.26.0",
"bootstrap": "^4.4.1",
"bootstrap-vue": "^2.12.0",
"cli": "^1.0.1",
"core-js": "^3.6.4",
"markdown-loader": "^5.1.0",
"marked": "^0.8.2",
"mavon-editor": "^2.8.3",
"register-service-worker": "^1.7.1",
"transform-runtime": "0.0.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"vue": "^2.6.11",
"vue-router": "^3.1.6"
},
"devDependencies": {
"#babel/cli": "^7.8.4",
"#babel/core": "^7.9.0",
"#babel/plugin-proposal-class-properties": "^7.4.4",
"#babel/plugin-transform-runtime": "^7.4.4",
"#babel/preset-env": "^7.9.5",
"#babel/runtime": "^7.4.5",
"#vue/cli-plugin-babel": "^4.3.1",
"#vue/cli-plugin-eslint": "^4.3.1",
"#vue/cli-plugin-pwa": "^4.3.1",
"#vue/cli-plugin-router": "^4.3.1",
"#vue/cli-service": "^4.3.1",
"babel-loader": "^7.1.5",
"compression-webpack-plugin": "^3.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"sass-loader": "^8.0.2",
"sass-resources-loader": "^2.0.3",
"style-loader": "^1.1.4",
"vue-markdown-loader": "^2.4.1",
"vue-template-compiler": "^2.6.11"
}
babel.config.js
module.exports = {
["#babel/preset-env", {
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}]
}
vue.config.js
const path = require('path');
const CompressionPlugin = require('compression-webpack-plugin')
// 配置代码压缩
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
/*配置cdn 引用加速*/
const cdn = {
css: ['https://cdn.bootcss.com/element-ui/2.13.1/theme-chalk/index.css',
'https://cdn.bootcss.com/twitter-bootstrap/4.4.1/css/bootstrap.min.css'
],
js: [
'https://cdn.bootcss.com/jquery/3.5.0/jquery.min.js',
'https://unpkg.com/vue/dist/vue.js',
'https://unpkg.com/element-ui/lib/index.js',
'https://cdn.bootcss.com/element-ui/2.13.1/index.js',
]
}
module.exports = {
publicPath: './',
outputDir: 'dist',
lintOnSave: true,
chainWebpack: (config) => {
config.module
.rule('images')
.use('image-webpack-loader')
.loader('image-webpack-loader')
.options({bypassOnDebug: true})
.end()
config.module.rule('md')
.test(/\.md/)
.use('vue-loader')
.loader('vue-loader')
.end()
.use('vue-markdown-loader')
.loader('vue-markdown-loader/lib/markdown-compiler')
.options({
raw: true
})
config.module.rule('js').test(/\.js$/).use('babel-loader').loader('babel-loader')
/* 配置 babel-loader */
const babel_loader = config.module.rule('babel-loader')
babel_loader.exclude.add(/(node_modules|bower_components)/)
babel_loader.test(/\.(e|j)s$/).use('babel-loader').loader('babel-loader')
if (process.env.NODE_ENV === 'production') {
config.plugin('html')
.tap(args => {
args[0].cdn = cdn;
return args;
});
if (process.env.npm_config_report) {
config
.plugin('webpack-bundle-analyzer')
.use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
.end();
config.plugins.delete('prefetch')
}
} else {
config.plugin('html')
.tap(args => {
args[0].cdn = cdn;
return args;
});
}
},
configureWebpack: (config) => {
config.entry.app = ["babel-polyfill", "./src/main.js"];
if (process.env.NODE_ENV === 'production') {
// 为生产环境修改配置...
config.mode = 'production'
return {
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
warnings: false,
compress: {
pure_funcs: ['console.log', 'console.debug']//移除console
}
}
})
]
},
externals: {
/* 包名 : 全局变量名*/
'vue': 'Vue',
/*
'vuex': 'Vuex',
'vue-router': 'VueRouter',
'axios': 'axios',*/
// "Bootstrap": "bootstrap",
"elementui": 'ElementUI ',
},
plugins: [
//生产环境自动删除console
/* new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false,
pure_funcs: ['console.log']//移除console
},
/!* compress: {
warnings: false,
drop_debugger: true,
drop_console: true,
},*!/
},
sourceMap: false,
parallel: true,
}),*/ new CompressionPlugin({
test: /\.js$|\.html$|\.css/, //匹配文件名
threshold: 10240, //对超过10k的数据进行压缩
deleteOriginalAssets: false //是否删除原文件
})]
}
} else if (process.env.NODE_ENV === 'development') {
config.mode = 'development';
Object.assign(config, {
resolve: {
alias: {
'#': path.resolve(__dirname, './src'),
'#c': path.resolve(__dirname, './src/components')
}
}
});
return {
externals: {
'vue': 'Vue',
"elementui": 'ElementUI ',
},
plugins: [new CompressionPlugin({
test: /\.js$|\.html$|\.css/,
threshold: 10240,
deleteOriginalAssets: false
})]
}
}
},
productionSourceMap: false,
css: {
extract: false,
sourceMap: false,
loaderOptions: {},
requireModuleExtension: false
},
parallel: require('os').cpus().length > 1,
pwa: {},
devServer: {
open: process.platform === 'darwin',
host: '0.0.0.0',
port: 2001,
https: false,
hotOnly: false,
open: true,
proxy: {
'/data': {
target: 'http://localhost:7000',
changeORIGIN: true
}
},
before: (app) => {
}
},
pluginOptions: {}
}
The above is the full configuration of my project. This problem has been bothering me for many days. I have tried many methods, but they have no effect
I'm trying to update my Aurelia project that uses webpack so I can require .scss files in my templates. I've looked at the Aurelia Skeleton project for webpack and have followed this guide to come up with my webpack.config which is listed below. I have also included my package.json file.
I am able to load styles now, but have come across a perplexing issue. None of the my bind statements work anymore. The code itself didn't change and was working fine before this update attempt. I tried using two-way, one-way, etc, but that didn't work either. The #bindable property is always undefined.
<my-custom-element value.bind="something"></my-custom-element>
In MyCustomElement, value is always undefined although something is set properly.
I have tried walking back the package versions and I think it has to do with aurelia-bootstrapper, but I'm not sure.
I'm out of ideas on how to debug this issue. Any help would be much appreciated.
webpack.config.js
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const DashboardPlugin = require('webpack-dashboard/plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const { AureliaPlugin, ModuleDependenciesPlugin } = require('aurelia-webpack-plugin');
const { optimize: { CommonsChunkPlugin }, ProvidePlugin } = require('webpack')
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const project = require('./package.json');
// config helpers:
const ensureArray = (config) => config && (Array.isArray(config) ? config : [config]) || []
const when = (condition, config, negativeConfig) =>
condition ? ensureArray(config) : ensureArray(negativeConfig)
// primary config:
const title = 'Radar';
const outDir = path.resolve(__dirname, 'dist');
const srcDir = path.resolve(__dirname, 'src');
const nodeModulesDir = path.resolve(__dirname, 'node_modules');
const baseUrl = '/';
// If not done this way the plugin will try to load when only a build is required and cause it to hang.
const addDashboardPlugin = process.env.npm_lifecycle_event === 'webpack' ? [] : [new DashboardPlugin({
port: 3333
})];
const metadata = {
port: process.env.WEBPACK_PORT || 9000,
host: process.env.WEBPACK_HOST || 'localhost'
};
const cssRules = [
{ loader: 'css-loader' },
{
loader: 'postcss-loader',
options: { plugins: () => [require('autoprefixer')({ browsers: ['last 2 versions'] })] }
}
]
module.exports = ({ production, server, extractCss, coverage } = {}) => ({
resolve: {
extensions: ['.js'],
modules: [srcDir, 'node_modules'],
},
entry: {
app: ['aurelia-bootstrapper'],
aurelia: Object.keys(project.dependencies).filter(dep => dep.startsWith('aurelia-')),
vendor: Object.keys(project.dependencies).filter(dep => !dep.startsWith('aurelia-'))
},
devtool: production ? 'source-map' : 'inline-source-map',
output: {
path: outDir,
publicPath: baseUrl,
filename: production ? '[name].[chunkhash].bundle.js' : '[name].[hash].bundle.js',
sourceMapFilename: production ? '[name].[chunkhash].bundle.map' : '[name].[hash].bundle.map',
chunkFilename: production ? '[name].[chunkhash].chunk.js' : '[name].[hash].chunk.js',
},
devServer: {
contentBase: outDir,
// serve index.html for all 404 (required for push-state)
historyApiFallback: true,
port: metadata.port,
host: metadata.host,
watchOptions: {
aggregateTimeout: 300,
poll: 1000
}
},
module: {
rules: [
{
test: /\.scss$/i,
issuer: [{ not: [{ test: /\.html$/i }] }],
loaders: ['style-loader', 'css-loader?sourceMap', 'sass-loader?sourceMap']
},
{
test: /\.scss$/i,
issuer: [{ test: /\.html$/i }],
loaders: ['css-loader?sourceMap', 'sass-loader?sourceMap']
},
// CSS required in JS/TS files should use the style-loader that auto-injects it into the website
// only when the issuer is a .js/.ts file, so the loaders are not applied inside html templates
{
test: /\.css$/i,
issuer: [{ not: [{ test: /\.html$/i }] }],
use: extractCss ? ExtractTextPlugin.extract({
fallback: 'style-loader',
use: cssRules,
}) : ['style-loader', ...cssRules],
},
{
test: /\.css$/i,
issuer: [{ test: /\.html$/i }],
// CSS required in templates cannot be extracted safely
// because Aurelia would try to require it again in runtime
use: cssRules,
},
{ test: /\.html$/i, loader: 'html-loader' },
{
test: /\.js$/i, loader: 'babel-loader', exclude: nodeModulesDir,
options: coverage ? { sourceMap: 'inline', plugins: ['istanbul'] } : {},
},
{ test: /\.json$/i, loader: 'json-loader' },
// use Bluebird as the global Promise implementation:
{ test: /[\/\\]node_modules[\/\\]bluebird[\/\\].+\.js$/, loader: 'expose-loader?Promise' },
// embed small images and fonts as Data Urls and larger ones as files:
{ test: /\.(png|gif|jpg|cur)$/i, loader: 'url-loader', options: { limit: 8192 } },
{ test: /\.woff2(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'url-loader', options: { limit: 10000, mimetype: 'application/font-woff2' } },
{ test: /\.woff(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'url-loader', options: { limit: 10000, mimetype: 'application/font-woff' } },
// load these fonts normally, as files:
{ test: /\.(ttf|eot|svg|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'file-loader' },
]
},
plugins: [
new AureliaPlugin(),
new ModuleDependenciesPlugin({
'aurelia-dialog': ['./ai-dialog', './ai-dialog-header', './ai-dialog-footer', './ai-dialog-body',
'./attach-focus', './dialog-configuration', './dialog-controller', './dialog-options', './dialog-renderer',
'./dialog-result', './dialog-service', './lifecycle', './renderer'],
'aurelia-chart': ['./elements/chart-element', './attributes/chart-attribute', './observers/model-observer']
}),
new ProvidePlugin({
'Promise': 'bluebird'
}),
new HtmlWebpackPlugin({
template: 'index.ejs',
minify: production ? {
removeComments: true,
collapseWhitespace: true
} : undefined,
metadata: {
title, server, baseUrl
},
}),
new CopyWebpackPlugin([
{ from: 'src/config', to: 'config' },
{ from: 'styles/img', to: 'img' }
]),
...when(extractCss, new ExtractTextPlugin({
filename: production ? '[contenthash].css' : '[id].css',
allChunks: true,
})),
...when(production, new CommonsChunkPlugin({
name: 'common'
})),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.scss$/i,
cssProcessor: require('cssnano'),
cssProcessorOptions: { discardComments: { removeAll: true } },
canPrint: true
})
].concat(addDashboardPlugin)
})
package.json
"dependencies": {
"aurelia-animator-css": "^1.0.0",
"aurelia-application-insights": "^1.0.0",
"aurelia-binding": "^1.2.0",
"aurelia-bootstrapper": "^2.1.1",
"aurelia-chart": "^0.2.6",
"aurelia-configuration": "1.0.17",
"aurelia-dependency-injection": "^1.3.1",
"aurelia-dialog": "^1.0.0-beta.3.0.0",
"aurelia-event-aggregator": "^1.0.1",
"aurelia-fetch-client": "^1.1.2",
"aurelia-framework": "^1.1.0",
"aurelia-history": "^1.0.0",
"aurelia-history-browser": "^1.0.0",
"aurelia-logging": "^1.3.1",
"aurelia-logging-console": "^1.0.0",
"aurelia-metadata": "^1.0.3",
"aurelia-notify": "^0.8.1",
"aurelia-pal": "^1.3.0",
"aurelia-pal-browser": "^1.1.0",
"aurelia-path": "^1.0.0",
"aurelia-route-recognizer": "^1.0.0",
"aurelia-router": "^1.3.0",
"aurelia-task-queue": "^1.2.0",
"aurelia-templating": "^1.3.0",
"aurelia-templating-binding": "^1.3.0",
"aurelia-templating-resources": "^1.3.1",
"aurelia-templating-router": "^1.1.0",
"aurelia-validation": "^1.0.0",
"bluebird": "^3.3.5",
"json-loader": "^0.5.4",
... //omitted for clarity
},
"devDependencies": {
"aurelia-loader-nodejs": "^1.0.1",
"aurelia-pal-nodejs": "^1.0.0-beta.1.0.0",
"aurelia-tools": "^1.0.0",
"aurelia-webpack-plugin": "^2.0.0-rc.2",
"autoprefixer": "^7.0.0",
"babel-core": "^6.17.0",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.0.0",
"babel-plugin-istanbul": "^4.1.3",
"babel-plugin-lodash": "^3.2.10",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-polyfill": "^6.16.0",
"babel-preset-env": "^1.5.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-1": "^6.24.1",
"babel-register": "^6.11.6",
"concurrently": "^2.2.0",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^3.1.3",
"css-loader": "^0.28.1",
"eslint": "^3.12.2",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.9.0",
"html-server": "^0.1.1",
"html-webpack-plugin": "^2.22.0",
"json-loader": "^0.5.4",
"node-sass": "^3.13.0",
"optimize-css-assets-webpack-plugin": "^1.3.2",
"package": "^1.0.1",
"postcss-loader": "^1.3.3",
"raw-loader": "^0.5.1",
"rimraf": "^2.5.2",
"sass-loader": "^4.0.2",
"style-loader": "^0.17.0",
"url-loader": "^0.5.8",
"webpack": "^2.6.1",
"webpack-dashboard": "^0.2.0",
"webpack-dev-server": "^2.4.5"
}
nav-bar.html
<template>
<require from='./_nav-bar.scss'></require>
<section class="nav-bar nav-bar__group" data-grid="full">
<div data-grid="full">
<main-menu router.bind="router" data-grid="21"></main-menu>
<user-panel data-grid="3"></user-panel>
</div>
</section>
</template>
main-menu.html
<template class="main-menu">
<ul class="main-menu__nav-list">
<li repeat.for="row of router.navigation">
<a href.bind="row.href"
data-appinsights-category="navigation"
data-appinsights-action="${row.title}"
data-text="${row.title}">
${row.title}
</a>
</li>
</ul>
</template>
main-menu.js
import { bindable, inject } from 'aurelia-framework';
#inject(Element)
export class MainMenuCustomElement {
//This value is always undefined now
#bindable router;
constructor(element) {
this.element = element;
}
toggleMenu() {
//removed for brevity
}
}
I got it to work after adding import babel-polyfill to main.js, changing .babelrc to reference `.babelrc.js like so:
{
"presets": [ "./.babelrc.js" ]
}
I also included .babelrc.js from the skeleton-navigation project.
.babelrc.js
// this file will be used by default by babel#7 once it is released
module.exports = {
"plugins": [
"transform-decorators-legacy",
"transform-class-properties"
],
"presets": [
[
"env", {
"targets": process.env.BABEL_TARGET === 'node' ? {
"node": process.env.IN_PROTRACTOR ? '6' : 'current'
} : {
"browsers": [
"last 2 versions",
"not ie <= 11"
],
"uglify": process.env.NODE_ENV === 'production',
},
"loose": true,
"modules": process.env.BABEL_TARGET === 'node' ? 'commonjs' : false,
"useBuiltIns": true
}
]
]
}