Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(vite): Migrate from webpack to vite #433

Merged
merged 3 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,6 @@ coverage_php
.phpunit.result.cache

.php-cs-fixer.cache

css/*
!css/unified-search.css
File renamed without changes.
33,375 changes: 9,064 additions & 24,311 deletions package-lock.json

Large diffs are not rendered by default.

66 changes: 9 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
"private": true,
"homepage": "https://github.com/raimund-schluessler/inventory",
"scripts": {
"build": "webpack --node-env production --progress",
"dev": "webpack --node-env development --progress",
"watch": "webpack --node-env development --progress --watch",
"build": "vite build --mode production",
"dev": "vite build --mode development",
"watch": "vite build --mode development --watch",
"lint": "eslint --ext .js,.vue src tests",
"lint:fix": "eslint --ext .js,.vue src tests --fix",
"test": "jest --verbose"
"test": "vitest run"
},
"repository": {
"type": "git",
"url": "git@github.com:raimund-schluessler/inventory.git"
},
"type": "module",
"bugs": "https://github.com/raimund-schluessler/inventory/issues",
"contributors": [],
"dependencies": {
Expand Down Expand Up @@ -53,67 +54,18 @@
"@nextcloud/browserslist-config": "3.0.0",
"@nextcloud/eslint-config": "^8.3.0",
"@nextcloud/stylelint-config": "2.3.1",
"@nextcloud/webpack-vue-config": "github:nextcloud/webpack-vue-config#master",
"@nextcloud/vite-config": "^1.2.0",
"@vue/test-utils": "^1.3.0",
"@vue/vue2-jest": "^29.2.6",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "29.7.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-serializer-vue": "3.1.0",
"jest-transform-stub": "^2.0.0",
"regenerator-runtime": "0.14.1"
"happy-dom": "^12.10.3",
"regenerator-runtime": "0.14.1",
"vitest": "^1.1.0"
},
"engines": {
"node": ">=15.0.0",
"npm": ">=7.17.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"vue"
],
"moduleNameMapper": {
"^@/(.*)$": "<rootDir>/src/$1",
"^Assets/(.*)$": "<rootDir>/src/assets/$1",
"^Components/(.*)$": "<rootDir>/src/components/$1",
"^Directives/(.*)$": "<rootDir>/src/directives/$1",
"^Fonts/(.*)$": "<rootDir>/src/fonts/$1",
"^Mixins/(.*)$": "<rootDir>/src/mixins/$1",
"^Models/(.*)$": "<rootDir>/src/models/$1",
"^Store/(.*)$": "<rootDir>/src/store/$1",
"^Utils/(.*)$": "<rootDir>/src/utils/$1",
"^.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
},
"testEnvironment": "jsdom",
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
".*\\.(vue)$": "<rootDir>/node_modules/@vue/vue2-jest",
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
},
"transformIgnorePatterns": [
"/node_modules/(?!(.*)/)"
],
"snapshotSerializers": [
"<rootDir>/node_modules/jest-serializer-vue"
],
"setupFilesAfterEnv": [
"./tests/javascript/unit/setup.js"
],
"coverageDirectory": "./coverage/",
"collectCoverage": true,
"collectCoverageFrom": [
"<rootDir>/src/**/*.{js,vue}",
"!**/node_modules/**"
],
"coverageReporters": [
"json",
"text",
"html",
"lcov",
"clover"
]
},
"browserslist": [
"extends @nextcloud/browserslist-config"
]
Expand Down
13 changes: 0 additions & 13 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,9 @@ import App from './App.vue'
import router from './router.js'
import store from './store/store.js'

import { linkTo } from '@nextcloud/router'

import Vue from 'vue'
import { sync } from 'vuex-router-sync'

// CSP config for webpack dynamic chunk loading
// eslint-disable-next-line
__webpack_nonce__ = btoa(OC.requestToken)

// Correct the root of the app for chunk loading
// OC.linkTo matches the apps folders
// OC.generateUrl ensure the index.php (or not)
// We do not want the index.php since we're loading files
// eslint-disable-next-line
__webpack_public_path__ = linkTo('inventory', 'js/')

sync(store, router)

if (!OCA.Inventory) {
Expand Down
1 change: 1 addition & 0 deletions templates/main.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php

script('inventory', 'inventory-main');
style('inventory', 'inventory-main');
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module.exports = {
env: {
jest: true,
},
// Do to https://github.com/benmosher/eslint-plugin-import/issues/1451
rules: {
'n/no-missing-import': ['off'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { mount, shallowMount, RouterLinkStub } from '@vue/test-utils'
import EntityTable from 'Components/EntityTable/EntityTable.vue'
import EntityTable from '../../../../../src/components/EntityTable/EntityTable.vue'
import { describe, expect, it } from 'vitest'

import { store, localVue } from '../../setupStore.js'

Expand Down
4 changes: 2 additions & 2 deletions tests/javascript/unit/setupStore.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'

import store from 'Store/store'
import Item from 'Models/item'
import store from '../../../src/store/store.js'
import Item from '../../../src/models/item.js'

const localVue = createLocalVue()
localVue.use(Vuex)
Expand Down
30 changes: 30 additions & 0 deletions vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { createAppConfig } from '@nextcloud/vite-config'
import { defineConfig } from 'vite'
import { resolve } from 'node:path'

const config = defineConfig({
build: {
sourcemap: false, // disabled, otherwise vite runs out of memory
},
test: {
coverage: {
include: ['src/**'],
provider: 'istanbul',
reporter: ['lcov', 'text'],
},
environment: 'happy-dom',
setupFiles: resolve(__dirname, './tests/javascript/unit/setup.js'),
alias: [{ find: /^vue$/, replacement: 'vue/dist/vue.runtime.common.js' }],
server: {
deps: {
inline: ['@nextcloud/vue'],
}
},
},
})

export default createAppConfig({
main: 'src/main.js',
}, {
config
})
3 changes: 0 additions & 3 deletions webpack.config.js

This file was deleted.

Loading