diff --git a/.eslintrc b/.eslintrc index 6a08036..aff2336 100644 --- a/.eslintrc +++ b/.eslintrc @@ -19,18 +19,22 @@ "prettier/prettier": ["error", { "endOfLine": "auto" }], + "import/extensions": "off", "import/no-unresolved": 0, "import/no-extraneous-dependencies": 0, "vue/no-v-html": "off", "vue/max-attributes-per-line": "off", "vue/singleline-html-element-content-newline": "off", "vue/html-closing-bracket-newline": "off", - "vue/html-self-closing": ["error", { - "html": { - "void": "always", - "normal": "never", - "component": "any" + "vue/html-self-closing": [ + "error", + { + "html": { + "void": "always", + "normal": "never", + "component": "any" + } } - }] + ] } } diff --git a/.husky/.gitignore b/.husky/.gitignore deleted file mode 100644 index 31354ec..0000000 --- a/.husky/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_ diff --git a/.husky/_/husky.sh b/.husky/_/husky.sh new file mode 100644 index 0000000..ca2720e --- /dev/null +++ b/.husky/_/husky.sh @@ -0,0 +1,30 @@ +#!/bin/sh +if [ -z "$husky_skip_init" ]; then + debug () { + [ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1" + } + + readonly hook_name="$(basename "$0")" + debug "starting $hook_name..." + + if [ "$HUSKY" = "0" ]; then + debug "HUSKY env variable is set to 0, skipping hook" + exit 0 + fi + + if [ -f ~/.huskyrc ]; then + debug "sourcing ~/.huskyrc" + . ~/.huskyrc + fi + + export readonly husky_skip_init=1 + sh -e "$0" "$@" + exitCode="$?" + + if [ $exitCode != 0 ]; then + echo "husky - $hook_name hook exited with code $exitCode (error)" + exit $exitCode + fi + + exit 0 +fi diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index 36af219..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx lint-staged diff --git a/.storybook/images/favicon.png b/.storybook/images/favicon.png new file mode 100644 index 0000000..aef9f15 Binary files /dev/null and b/.storybook/images/favicon.png differ diff --git a/.storybook/main.js b/.storybook/main.js new file mode 100644 index 0000000..674e57d --- /dev/null +++ b/.storybook/main.js @@ -0,0 +1,55 @@ +const path = require('path') + +module.exports = { + core: { + builder: 'webpack5' + }, + stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], + addons: [ + '@storybook/preset-scss', + '@storybook/addon-links', + '@storybook/addon-essentials', + { + name: '@storybook/addon-docs', + options: { + vueDocgenOptions: { + alias: { + '@': path.resolve(__dirname, '../') + } + } + } + }, + { + name: '@storybook/addon-postcss', + options: { + cssLoaderOptions: { + // When you have splitted your css over multiple files + // and use @import('./other-styles.css') + importLoaders: 1 + }, + postcssLoaderOptions: { + implementation: require('postcss') + } + } + } + ], + webpackFinal: async (config) => { + config.resolve.alias['@'] = path.resolve(__dirname, '../src') + config.module.rules.push({ + test: /\.(s[ac]ss|css)$/, + use: [ + 'postcss-loader', + { + loader: 'sass-loader', + options: { + sassOptions: { + indentWidth: 4, + includePaths: [] + } + } + } + ] + }) + return config + } +} diff --git a/.storybook/manager-head.html b/.storybook/manager-head.html new file mode 100644 index 0000000..10c347f --- /dev/null +++ b/.storybook/manager-head.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.storybook/manager.js b/.storybook/manager.js new file mode 100644 index 0000000..e5aa7d6 --- /dev/null +++ b/.storybook/manager.js @@ -0,0 +1,6 @@ +import { addons } from '@storybook/addons' +import UnknownTheme from './unknown-theme' + +addons.setConfig({ + theme: UnknownTheme +}) diff --git a/.storybook/preview.js b/.storybook/preview.js new file mode 100644 index 0000000..7233fbd --- /dev/null +++ b/.storybook/preview.js @@ -0,0 +1,17 @@ +import '../style/tailwind.scss' +import '../style/main.scss' + +import { themes } from '@storybook/theming' + +export const parameters = { + actions: { argTypesRegex: '^on[A-Z].*' }, + controls: { + matchers: { + color: /(background|color)$/i, + date: /Date$/ + } + }, + docs: { + theme: themes.dark + } +} diff --git a/.storybook/unknown-theme.js b/.storybook/unknown-theme.js new file mode 100644 index 0000000..9edd0da --- /dev/null +++ b/.storybook/unknown-theme.js @@ -0,0 +1,10 @@ +import { create } from '@storybook/theming' + +export default create({ + base: 'dark', + brandTitle: 'IUnknown Storybook', + brandUrl: 'https://theunknown.ch', + fontBase: '"Roboto", sans-serif', + fontCode: 'monospace', + brandImage: 'https://theunknown.ch/version/1620234786727/static/images/unk-logo.png' +}) diff --git a/README.md b/README.md index 41411eb..85d9a7e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -# Vue Skeleton +# Vue Unknown ## A web framework based on Vue 3 - # Features - [Vuex](https://next.vuex.vuejs.org/) @@ -10,13 +9,13 @@ - [Webpack](https://webpack.js.org/) - [Tailwind CSS](https://tailwindcss.com/) - [Service Worker](https://developers.google.com/web/tools/workbox/modules/workbox-webpack-plugin) +- [Storybook](https://storybook.js.org/) - [SCSS](https://sass-lang.com/) - [Favicon Generator](https://github.com/jantimon/favicons-webpack-plugin) -- [Axios](https://github.com/axios/axios) - [Airbnb Coding Standard](https://github.com/airbnb/javascript) - [Prettier](https://prettier.io/) - [Lint Staged](https://github.com/okonet/lint-staged) # Documentation -- [Vue Skeleton: Wiki](https://github.com/the-unknown-code/vue-skeleton/wiki/Documentation) -- [Vue Skeleton: Template generator]() +- [Vue Unknown: Wiki](https://github.com/the-unknown-code/vue-unknown/wiki/Documentation) +- [Vue Unknown: Template generator]() diff --git a/dev-tools/config/scripts/build.js b/dev-tools/config/scripts/build.js index 87fbb3a..e63cb83 100644 --- a/dev-tools/config/scripts/build.js +++ b/dev-tools/config/scripts/build.js @@ -8,7 +8,7 @@ const chalk = require('chalk') const webpack = require('webpack') const webpackConfig = require('../webpack.config.prod') -const spinner = ora('Vue Skeleton: Building for production') +const spinner = ora('Vue Unknown: Building for production') spinner.start() fs.emptyDirSync(webpackConfig.output.path) @@ -39,7 +39,7 @@ webpack(webpackConfig, (err, stats) => { ) console.log() - console.log(chalk.blue('Vue Skeleton: You can preview your build by running:'), chalk.blue.bold('yarn preview')) - console.log(chalk.blue('Vue Skeleton: You can analyze your build by running:'), chalk.blue.bold('yarn analyze')) + console.log(chalk.blue('Vue Unknown: You can preview your build by running:'), chalk.blue.bold('yarn preview')) + console.log(chalk.blue('Vue Unknown: You can analyze your build by running:'), chalk.blue.bold('yarn analyze')) console.log() }) diff --git a/dev-tools/config/webpack.config.dev.js b/dev-tools/config/webpack.config.dev.js index 3db843a..1da830e 100644 --- a/dev-tools/config/webpack.config.dev.js +++ b/dev-tools/config/webpack.config.dev.js @@ -17,13 +17,13 @@ module.exports = detectPort(config.devServer.port).then((port) => { devWebpackConfig.plugins.push( new FriendlyErrorsWebpackPlugin({ compilationSuccessInfo: { - messages: [`Vue Skeleton - Your application is running here: ${config.devServer.useHttps ? 'https' : 'http'}://localhost:${port}`] + messages: [`Vue Unknown - Your application is running here: ${config.devServer.useHttps ? 'https' : 'http'}://localhost:${port}`] } }) ) } else { // eslint-disable-next-line no-throw-literal - throw 'Vue Skeleton: Plugins not declared' + throw 'Vue Unknown: Plugins not declared' } return devWebpackConfig diff --git a/dev-tools/config/webpack.helpers.js b/dev-tools/config/webpack.helpers.js index c1827ef..5668d5d 100644 --- a/dev-tools/config/webpack.helpers.js +++ b/dev-tools/config/webpack.helpers.js @@ -7,5 +7,9 @@ exports.compose = (funcs) => { return funcs[0] } - return funcs.reduce((a, b) => (...args) => a(b(...args))) + return funcs.reduce( + (a, b) => + (...args) => + a(b(...args)) + ) } diff --git a/dev-tools/config/webpack.module.optimize.js b/dev-tools/config/webpack.module.optimize.js index 60f1693..2029771 100644 --- a/dev-tools/config/webpack.module.optimize.js +++ b/dev-tools/config/webpack.module.optimize.js @@ -1,44 +1,54 @@ const TerserPlugin = require('terser-webpack-plugin') const CssMinimizerPlugin = require('css-minimizer-webpack-plugin') -module.exports = ({ config, isDevelopment }) => (webpackConfig) => ({ - ...webpackConfig, - optimization: isDevelopment - ? { - noEmitOnErrors: true - } - : { - minimize: true, - minimizer: [ - (compiler) => { - new TerserPlugin({ - parallel: true, - extractComments: false, - terserOptions: { - compress: { - drop_console: true +module.exports = + ({ config, isDevelopment }) => + (webpackConfig) => ({ + ...webpackConfig, + optimization: isDevelopment + ? { + noEmitOnErrors: true + } + : { + minimize: true, + minimizer: [ + (compiler) => { + new TerserPlugin({ + parallel: true, + extractComments: false, + terserOptions: { + compress: { + drop_console: true + } } - } - }).apply(compiler) - }, - new CssMinimizerPlugin() - ], - runtimeChunk: 'single', - splitChunks: { - cacheGroups: { - vendor: { - test: /[\\/]node_modules[\\/]/, - name: 'vendors', - chunks: 'all', - priority: -10, - reuseExistingChunk: true + }).apply(compiler) }, - default: { - minChunks: 2, - priority: -20, - reuseExistingChunk: true + new CssMinimizerPlugin() + ], + removeAvailableModules: false, + removeEmptyChunks: false, + splitChunks: false + + /* + splitChunks: { + chunks: 'all', + maxInitialRequests: Infinity, + minSize: 0, + cacheGroups: { + vendor: { + test: /[\\/]node_modules[\\/]/, + name(module) { + // get the name. E.g. node_modules/packageName/not/this/part.js + // or node_modules/packageName + const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1] + + // npm package names are URL-safe, but some servers don't like @ symbols + return `npm.${packageName.replace('@', '')}` + } + } } } + + */ } - } -}) + }) diff --git a/dev-tools/config/webpack.module.output.js b/dev-tools/config/webpack.module.output.js index 17f6c16..c794040 100644 --- a/dev-tools/config/webpack.module.output.js +++ b/dev-tools/config/webpack.module.output.js @@ -1,11 +1,13 @@ const path = require('path') -module.exports = ({ config, isDevelopment = true }) => (webpackConfig) => ({ - ...webpackConfig, - output: { - path: path.join(config.projectRoot, 'dist', config.dist.publicPath !== '/' ? config.dist.publicPath : ''), - publicPath: isDevelopment ? '/' : config.dist.publicPath, - filename: isDevelopment ? '[name].js' : path.posix.join('', `${config.dist.versionPath}js/[name].js`), - chunkFilename: isDevelopment ? '[id].js' : path.posix.join('', `${config.dist.versionPath}js/[id].js`) - } -}) +module.exports = + ({ config, isDevelopment = true }) => + (webpackConfig) => ({ + ...webpackConfig, + output: { + path: path.join(config.projectRoot, 'dist', config.dist.publicPath !== '/' ? config.dist.publicPath : ''), + publicPath: isDevelopment ? '/' : config.dist.publicPath, + filename: isDevelopment ? '[name].js' : path.posix.join('', `${config.dist.versionPath}js/[name].js`), + chunkFilename: isDevelopment ? '[id].js' : path.posix.join('', `${config.dist.versionPath}js/[id].js`) + } + }) diff --git a/dev-tools/config/webpack.module.plugins.js b/dev-tools/config/webpack.module.plugins.js index a55e4f1..ad96142 100644 --- a/dev-tools/config/webpack.module.plugins.js +++ b/dev-tools/config/webpack.module.plugins.js @@ -6,130 +6,120 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin') const WorkboxPlugin = require('workbox-webpack-plugin') const BeautifyHtmlWebpackPlugin = require('beautify-html-webpack-plugin') -const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin') const FaviconsWebpackPlugin = require('favicons-webpack-plugin') const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') const { CleanWebpackPlugin } = require('clean-webpack-plugin') const { VueLoaderPlugin } = require('vue-loader') -module.exports = ({ config, buildType, isDevelopment }) => (webpackConfig) => { - const plugins = [ - new CopyWebpackPlugin({ - patterns: [ - { - from: 'static', - to: isDevelopment ? 'static' : `${config.dist.versionPath}static` - }, - { - from: 'static-root', - to: '' - } - ] - }), - new HtmlWebpackPlugin( - isDevelopment - ? { - filename: config.devServer.indexHtml, - template: 'index.html', - inject: true, - version: config.dist.versionPath, - publicPath: config.dist.publicPath, - minify: { - removeComments: true, - collapseWhitespace: true, - removeAttributeQuotes: false - }, - chunksSortMode: 'none' - } - : { - publicPath: config.dist.publicPath, - filename: 'index.html', - template: 'index.html', - version: '/', - inject: 'body', - cache: true, - clean: true +module.exports = + ({ config, buildType, isDevelopment }) => + (webpackConfig) => { + const plugins = [ + new CopyWebpackPlugin({ + patterns: [ + { + from: 'static', + to: isDevelopment ? 'static' : `${config.dist.versionPath}static` + }, + { + from: 'static-root', + to: '' } - ), - new webpack.DefinePlugin({ - 'process.env': config.env[buildType], - __VUE_OPTIONS_API__: true, - __VUE_PROD_DEVTOOLS__: false - }), - - new CleanWebpackPlugin(), - new MiniCssExtractPlugin({ - filename: path.posix.join(config.dist.versionPath, 'css/[name].css') - }), - new WebpackBar(), - new VueLoaderPlugin(), - new ImageMinimizerPlugin({ - minimizerOptions: { - // Lossless optimization with custom option - // Feel free to experiment with options for better result for you - plugins: [ - ['gifsicle', { interlaced: true }], - ['jpegtran', { progressive: true }], - ['optipng', { optimizationLevel: 5 }] ] - } - }) - ] + }), + new HtmlWebpackPlugin( + isDevelopment + ? { + filename: config.devServer.indexHtml, + template: 'index.html', + inject: true, + version: config.dist.versionPath, + publicPath: config.dist.publicPath, + minify: { + removeComments: true, + collapseWhitespace: true, + removeAttributeQuotes: false + }, + chunksSortMode: 'none' + } + : { + publicPath: config.dist.publicPath, + filename: 'index.html', + template: 'index.html', + version: '/', + inject: 'body', + cache: true, + clean: true + } + ), + new webpack.DefinePlugin({ + 'process.env': config.env[buildType], + __VUE_OPTIONS_API__: true, + __VUE_PROD_DEVTOOLS__: false + }), - /* - * Hot Module Replacement (or HMR) is one of the most useful features offered by webpack. - * It allows all kinds of modules to be updated at runtime without the need for a full refresh. - */ - if (isDevelopment) { - plugins.push(new webpack.HotModuleReplacementPlugin()) - } else { - plugins.push( - new WorkboxPlugin.GenerateSW({ - // these options encourage the ServiceWorkers to get in there fast - // and not allow any straggling "old" SWs to hang around - clientsClaim: true, - skipWaiting: true + new CleanWebpackPlugin(), + new MiniCssExtractPlugin({ + filename: path.posix.join(config.dist.versionPath, 'css/[name].css') }), - new BeautifyHtmlWebpackPlugin() - ) + new WebpackBar(), + new VueLoaderPlugin() + ] - if (config.generateFavIcon) { + /* + * Hot Module Replacement (or HMR) is one of the most useful features offered by webpack. + * It allows all kinds of modules to be updated at runtime without the need for a full refresh. + */ + if (isDevelopment) { + plugins.push(new webpack.HotModuleReplacementPlugin()) + } else { plugins.push( - new FaviconsWebpackPlugin({ - logo: path.join(config.projectRoot, 'static/favicon.png'), - prefix: `${config.dist.versionPath}static/favicon/`, - cache: true, - inject: true, - favicons: { - icons: { - android: true, - appleIcon: true, - appleStartup: false, - coast: false, - favicons: true, - firefox: false, - opengraph: false, - twitter: false, - yandex: false, - windows: false + new WorkboxPlugin.GenerateSW({ + // these options encourage the ServiceWorkers to get in there fast + // and not allow any straggling "old" SWs to hang around + clientsClaim: true, + skipWaiting: true + }), + new BeautifyHtmlWebpackPlugin() + ) + + if (config.generateFavIcon) { + plugins.push( + new FaviconsWebpackPlugin({ + logo: path.join(config.projectRoot, 'static/favicon.png'), + prefix: `${config.dist.versionPath}static/favicon/`, + cache: true, + inject: true, + favicons: { + icons: { + android: true, + appleIcon: true, + appleStartup: false, + coast: false, + favicons: true, + firefox: false, + opengraph: false, + twitter: false, + yandex: false, + windows: false + } } - } + }) + ) + } + } + + // Visualize size of webpack output files with an interactive zoomable treemap. + if (config.enableBundleAnalyzer) { + plugins.push( + new BundleAnalyzerPlugin({ + defaultSizes: 'gzip' }) ) } - } - // Visualize size of webpack output files with an interactive zoomable treemap. - if (config.enableBundleAnalyzer) { - plugins.push( - new BundleAnalyzerPlugin({ - defaultSizes: 'gzip' - }) - ) - } - - return { - ...webpackConfig, - plugins + return { + ...webpackConfig, + plugins + } } -} diff --git a/dev-tools/config/webpack.module.resolve.js b/dev-tools/config/webpack.module.resolve.js index f8b8c18..2da7b58 100644 --- a/dev-tools/config/webpack.module.resolve.js +++ b/dev-tools/config/webpack.module.resolve.js @@ -1,17 +1,19 @@ const path = require('path') -module.exports = ({ config }) => (webpackConfig) => ({ - ...webpackConfig, - resolve: { - extensions: ['.ts', '.js', '.vue', '.json'], - alias: { - vue: 'vue/dist/vue.esm-bundler.js', - '@': path.resolve(config.projectRoot, 'src') - /* - * You are running the esm-bundler build of vue-i18n. - * It is recommended to configure your bundler to explicitly replace feature flag globals - * with boolean literals to get proper tree-shaking in the final bundle. - */ +module.exports = + ({ config }) => + (webpackConfig) => ({ + ...webpackConfig, + resolve: { + extensions: ['.ts', '.js', '.vue', '.json'], + alias: { + vue: 'vue/dist/vue.esm-bundler.js', + '@': path.resolve(config.projectRoot, 'src') + /* + * You are running the esm-bundler build of vue-i18n. + * It is recommended to configure your bundler to explicitly replace feature flag globals + * with boolean literals to get proper tree-shaking in the final bundle. + */ + } } - } -}) + }) diff --git a/dev-tools/config/webpack.module.rules.js b/dev-tools/config/webpack.module.rules.js index c0c7e48..0350f1b 100644 --- a/dev-tools/config/webpack.module.rules.js +++ b/dev-tools/config/webpack.module.rules.js @@ -2,123 +2,125 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin') const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin') const path = require('path') -module.exports = ({ config, isDevelopment }) => (webpackConfig) => ({ - ...webpackConfig, - module: { - rules: [ - isDevelopment - ? { - test: /\.(s[ac]ss|css)$/, - use: [ - 'style-loader', - 'css-loader', - 'postcss-loader', - { - loader: 'sass-loader', - options: { - sassOptions: { - indentWidth: 4, - includePaths: [] +module.exports = + ({ config, isDevelopment }) => + (webpackConfig) => ({ + ...webpackConfig, + module: { + rules: [ + isDevelopment + ? { + test: /\.(s[ac]ss|css)$/, + use: [ + 'style-loader', + 'css-loader', + 'postcss-loader', + { + loader: 'sass-loader', + options: { + sassOptions: { + indentWidth: 4, + includePaths: [] + } } } - } - ] - } - : { - test: /\.(s[ac]ss|css)$/, - use: [ - MiniCssExtractPlugin.loader, - 'css-loader', - 'postcss-loader', - { - loader: 'sass-loader', - options: { - sassOptions: { - indentWidth: 4, - includePaths: [] + ] + } + : { + test: /\.(s[ac]ss|css)$/, + use: [ + MiniCssExtractPlugin.loader, + 'css-loader', + 'postcss-loader', + { + loader: 'sass-loader', + options: { + sassOptions: { + indentWidth: 4, + includePaths: [] + } } } - } - ] - }, - { - test: /\.vue$/, - loader: 'vue-loader' - }, - { - test: /\.js$/, - exclude: /node_modules/, - // use: ['babel-loader', 'eslint-loader'] + ] + }, + { + test: /\.vue$/, + loader: 'vue-loader' + }, + { + test: /\.js$/, + exclude: /node_modules/, + // use: ['babel-loader', 'eslint-loader'] - use: [ - { - loader: 'babel-loader', + use: [ + { + loader: 'babel-loader?cacheDirectory', + options: { + presets: ['@babel/preset-env'] + } + } + ] + }, + { + test: /\.ts$/, + exclude: /node_modules/, + use: [ + { + loader: 'babel-loader?cacheDirectory', + options: { babelrc: true } + }, + { + loader: 'ts-loader', + options: { appendTsSuffixTo: [/\.vue$/] } + } + ] + }, + { + test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, + use: { + loader: 'file-loader', options: { - presets: ['@babel/preset-env'] + limit: 10000, + name: path.posix.join(isDevelopment ? '' : config.dist.versionPath, 'fonts/[name].[ext]') } } - ] - }, - { - test: /\.ts$/, - exclude: /node_modules/, - use: [ - { - loader: 'babel-loader', - options: { babelrc: true } - }, - { - loader: 'ts-loader', - options: { appendTsSuffixTo: [/\.vue$/] } - } - ] - }, - { - test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, - use: { - loader: 'file-loader', - options: { - limit: 10000, - name: path.posix.join(isDevelopment ? '' : config.dist.versionPath, 'fonts/[name].[ext]') - } - } - }, - { - test: /\.(?:ico|gif|png|jpg|jpeg|svg)$/i, - type: 'asset/resource' - }, - { - test: /\.(ico|gif|png|jpg|jpeg|svg)$/i, - use: [ - { - loader: ImageMinimizerPlugin.loader, - options: { - severityError: 'warning', // Ignore errors on corrupted images - minimizerOptions: { - plugins: ['gifsicle'] + }, + { + test: /\.(?:ico|gif|png|jpg|jpeg|svg)$/i, + type: 'asset/resource' + }, + { + test: /\.(ico|gif|png|jpg|jpeg|svg)$/i, + use: [ + { + loader: ImageMinimizerPlugin.loader, + options: { + severityError: 'warning', // Ignore errors on corrupted images + minimizerOptions: { + plugins: ['gifsicle'] + } } } - } - ] - }, - { - test: /\.svg$/, - use: [ - { - loader: 'file-loader' - }, - { - loader: 'svgo-loader', - options: { - multipass: true, - js2svg: { - indent: 2, - pretty: true + ] + }, + { + test: /\.svg$/, + use: [ + { + loader: 'file-loader' + }, + { + loader: 'svgo-loader', + options: { + multipass: true, + js2svg: { + indent: 2, + pretty: true + } } } - } - ] - } - ] - } -}) + ] + } + ] + } + }) diff --git a/dev-tools/config/webpack.module.server.js b/dev-tools/config/webpack.module.server.js index e47deef..d36d8b6 100644 --- a/dev-tools/config/webpack.module.server.js +++ b/dev-tools/config/webpack.module.server.js @@ -1,20 +1,22 @@ const fs = require('fs') -module.exports = ({ config }) => (webpackConfig) => ({ - ...webpackConfig, - devServer: { - https: config.devServer.useHttps, - clientLogLevel: 'info', - historyApiFallback: true, - hot: true, - compress: true, - host: 'localhost', - port: config.devServer.port, - disableHostCheck: true, - open: false, - overlay: { - warning: false, - errors: true +module.exports = + ({ config }) => + (webpackConfig) => ({ + ...webpackConfig, + devServer: { + https: config.devServer.useHttps, + clientLogLevel: 'info', + historyApiFallback: true, + hot: true, + compress: true, + host: '0.0.0.0', + port: config.devServer.port, + disableHostCheck: true, + open: false, + overlay: { + warning: false, + errors: true + } } - } -}) + }) diff --git a/dev-tools/scripts/bin/generate-component.js b/dev-tools/scripts/bin/generate-component.js index ea8ab0b..99bf6f4 100644 --- a/dev-tools/scripts/bin/generate-component.js +++ b/dev-tools/scripts/bin/generate-component.js @@ -29,7 +29,8 @@ if (fs.existsSync(targetFolder)) { copyFolderRecursiveSync(source, destination) renamePath(`${destination}{name_pc}`, `${destination}${componentName}`) -renamePath(`${destination}${componentName}\\{name_pc}.js`, `${destination}${componentName}\\${componentName}.js`) -renamePath(`${destination}${componentName}\\{name_pc}.vue`, `${destination}${componentName}\\${componentName}.vue`) -replaceInFile(`${destination}${componentName}\\${componentName}.js`, componentName) -replaceInFile(`${destination}${componentName}\\${componentName}.vue`, componentName) +renamePath(`${destination}${componentName}/{name_pc}.js`, `${destination}${componentName}/${componentName}.js`) +renamePath(`${destination}${componentName}/{name_pc}.vue`, `${destination}${componentName}/${componentName}.vue`) +replaceInFile(`${destination}${componentName}/index.js`, componentName) +replaceInFile(`${destination}${componentName}/${componentName}.js`, componentName) +replaceInFile(`${destination}${componentName}/${componentName}.vue`, componentName) diff --git a/dev-tools/scripts/bin/generate-page.js b/dev-tools/scripts/bin/generate-page.js index 4838d79..38ae135 100644 --- a/dev-tools/scripts/bin/generate-page.js +++ b/dev-tools/scripts/bin/generate-page.js @@ -29,7 +29,8 @@ if (fs.existsSync(targetFolder)) { copyFolderRecursiveSync(source, destination) renamePath(`${destination}{name_pc}`, `${destination}${pageName}`) -renamePath(`${destination}${pageName}\\{name_pc}.js`, `${destination}${pageName}\\${pageName}.js`) -renamePath(`${destination}${pageName}\\{name_pc}.vue`, `${destination}${pageName}\\${pageName}.vue`) -replaceInFile(`${destination}${pageName}\\${pageName}.js`, pageName) -replaceInFile(`${destination}${pageName}\\${pageName}.vue`, pageName) +renamePath(`${destination}${pageName}/name_pc}.js`, `${destination}${pageName}/${pageName}.js`) +renamePath(`${destination}${pageName}/{name_pc}.vue`, `${destination}${pageName}/${pageName}.vue`) +replaceInFile(`${destination}${pageName}/index.js`, pageName) +replaceInFile(`${destination}${pageName}/${pageName}.js`, pageName) +replaceInFile(`${destination}${pageName}/${pageName}.vue`, pageName) diff --git a/dev-tools/scripts/bin/generate.js b/dev-tools/scripts/bin/generate.js index dfa1f4d..b61ea87 100644 --- a/dev-tools/scripts/bin/generate.js +++ b/dev-tools/scripts/bin/generate.js @@ -2,7 +2,7 @@ const program = require('commander') const chalk = require('chalk') -console.log(chalk.blue('Vue Skeleton Generator')) +console.log(chalk.blue('Vue Unknown Generator')) console.log() program diff --git a/dev-tools/scripts/package.json b/dev-tools/scripts/package.json index 577cf75..683ee2d 100644 --- a/dev-tools/scripts/package.json +++ b/dev-tools/scripts/package.json @@ -1,8 +1,7 @@ { - "name": "vue-skeleton-generator", - "version": "1.0.0", - "description": "A Vue CLI generator to create code based on templates", - "preferGlobal": true, - "license": "MIT" - } - \ No newline at end of file + "name": "vue-unknown-generator", + "version": "1.0.0", + "description": "A Vue CLI generator to create code based on templates", + "preferGlobal": true, + "license": "MIT" +} diff --git a/dev-tools/scripts/templates/component/{name_pc}/index.js b/dev-tools/scripts/templates/component/{name_pc}/index.js new file mode 100644 index 0000000..4888712 --- /dev/null +++ b/dev-tools/scripts/templates/component/{name_pc}/index.js @@ -0,0 +1,3 @@ +import {{name_pc}} from './{{name_pc}}.vue' + +export default {{name_pc}} \ No newline at end of file diff --git a/dev-tools/scripts/templates/directive/{name_pc}.js b/dev-tools/scripts/templates/directive/{name_pc}.js deleted file mode 100644 index f500f71..0000000 --- a/dev-tools/scripts/templates/directive/{name_pc}.js +++ /dev/null @@ -1,7 +0,0 @@ -// Directive template - -export default { - name: '{{name_pc}}', - beforeMount(el, binding, vnode) {}, - beforeUnmount(el, binding, vnode) {} -} diff --git a/dev-tools/scripts/templates/page/index.js b/dev-tools/scripts/templates/page/index.js new file mode 100644 index 0000000..4888712 --- /dev/null +++ b/dev-tools/scripts/templates/page/index.js @@ -0,0 +1,3 @@ +import {{name_pc}} from './{{name_pc}}.vue' + +export default {{name_pc}} \ No newline at end of file diff --git a/dev-tools/scripts/templates/store/{name_pc}/{name_pc}.js b/dev-tools/scripts/templates/store/{name_pc}/{name_pc}.js deleted file mode 100644 index 12cd6a2..0000000 --- a/dev-tools/scripts/templates/store/{name_pc}/{name_pc}.js +++ /dev/null @@ -1,8 +0,0 @@ -const namespace = '{{name_pc}}' - -export default { - state: {}, - getters: {}, - mutations: {}, - actions: {} -} diff --git a/index.html b/index.html index 830f529..ee53688 100644 --- a/index.html +++ b/index.html @@ -1,14 +1,16 @@ -
- - - -