Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit 7c2a6a5

Browse files
authored
Re init project (#1)
* feat: delete all project * feat: recreate the project using sfc-init
1 parent fb57d40 commit 7c2a6a5

28 files changed

+12888
-8953
lines changed

.browserslistrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
current node
2+
last 2 versions and > 2%
3+
ie > 10

.github/workflows/npm-publish.yml

-47
This file was deleted.

README.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,17 @@
22

33
## Project setup
44
```
5-
yarn install
5+
npm install
66
```
77

88
### Compiles and hot-reloads for development
99
```
10-
yarn serve
10+
npm run serve
1111
```
1212

1313
### Compiles and minifies for production
1414
```
15-
yarn build
16-
```
17-
18-
### Lints and fixes files
19-
```
20-
yarn lint
15+
npm run build
2116
```
2217

2318
### Customize configuration

babel.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const devPresets = ['@vue/babel-preset-app'];
2+
const buildPresets = ['@babel/preset-env', '@babel/preset-typescript'];
13
module.exports = {
2-
presets: ["@vue/cli-plugin-babel/preset"]
4+
presets: (process.env.NODE_ENV === 'development' ? devPresets : buildPresets),
35
};

build/rollup.config.js

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
// rollup.config.js
2+
import fs from 'fs';
3+
import path from 'path';
4+
import vue from 'rollup-plugin-vue';
5+
import alias from '@rollup/plugin-alias';
6+
import commonjs from '@rollup/plugin-commonjs';
7+
import replace from '@rollup/plugin-replace';
8+
import babel from 'rollup-plugin-babel';
9+
import { terser } from 'rollup-plugin-terser';
10+
import minimist from 'minimist';
11+
12+
// Get browserslist config and remove ie from es build targets
13+
const esbrowserslist = fs.readFileSync('./.browserslistrc')
14+
.toString()
15+
.split('\n')
16+
.filter((entry) => entry && entry.substring(0, 2) !== 'ie');
17+
18+
const argv = minimist(process.argv.slice(2));
19+
20+
const projectRoot = path.resolve(__dirname, '..');
21+
22+
const baseConfig = {
23+
input: 'src/entry.ts',
24+
plugins: {
25+
preVue: [
26+
alias({
27+
resolve: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
28+
entries: {
29+
'@': path.resolve(projectRoot, 'src'),
30+
},
31+
}),
32+
],
33+
replace: {
34+
'process.env.NODE_ENV': JSON.stringify('production'),
35+
'process.env.ES_BUILD': JSON.stringify('false'),
36+
},
37+
vue: {
38+
css: true,
39+
template: {
40+
isProduction: true,
41+
},
42+
},
43+
babel: {
44+
exclude: 'node_modules/**',
45+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
46+
},
47+
},
48+
};
49+
50+
// ESM/UMD/IIFE shared settings: externals
51+
// Refer to https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
52+
const external = [
53+
// list external dependencies, exactly the way it is written in the import statement.
54+
// eg. 'jquery'
55+
'vue',
56+
];
57+
58+
// UMD/IIFE shared settings: output.globals
59+
// Refer to https://rollupjs.org/guide/en#output-globals for details
60+
const globals = {
61+
// Provide global variable names to replace your external imports
62+
// eg. jquery: '$'
63+
vue: 'Vue',
64+
};
65+
66+
// Customize configs for individual targets
67+
const buildFormats = [];
68+
if (!argv.format || argv.format === 'es') {
69+
const esConfig = {
70+
...baseConfig,
71+
external,
72+
output: {
73+
file: 'dist/vue-typed.esm.js',
74+
format: 'esm',
75+
exports: 'named',
76+
},
77+
plugins: [
78+
replace({
79+
...baseConfig.plugins.replace,
80+
'process.env.ES_BUILD': JSON.stringify('true'),
81+
}),
82+
...baseConfig.plugins.preVue,
83+
vue(baseConfig.plugins.vue),
84+
babel({
85+
...baseConfig.plugins.babel,
86+
presets: [
87+
[
88+
'@babel/preset-env',
89+
{
90+
targets: esbrowserslist,
91+
},
92+
],
93+
],
94+
}),
95+
commonjs(),
96+
],
97+
};
98+
buildFormats.push(esConfig);
99+
}
100+
101+
if (!argv.format || argv.format === 'cjs') {
102+
const umdConfig = {
103+
...baseConfig,
104+
external,
105+
output: {
106+
compact: true,
107+
file: 'dist/vue-typed.ssr.js',
108+
format: 'cjs',
109+
name: 'VueTyped',
110+
exports: 'named',
111+
globals,
112+
},
113+
plugins: [
114+
replace(baseConfig.plugins.replace),
115+
...baseConfig.plugins.preVue,
116+
vue({
117+
...baseConfig.plugins.vue,
118+
template: {
119+
...baseConfig.plugins.vue.template,
120+
optimizeSSR: true,
121+
},
122+
}),
123+
babel(baseConfig.plugins.babel),
124+
commonjs(),
125+
],
126+
};
127+
buildFormats.push(umdConfig);
128+
}
129+
130+
if (!argv.format || argv.format === 'iife') {
131+
const unpkgConfig = {
132+
...baseConfig,
133+
external,
134+
output: {
135+
compact: true,
136+
file: 'dist/vue-typed.min.js',
137+
format: 'iife',
138+
name: 'VueTyped',
139+
exports: 'named',
140+
globals,
141+
},
142+
plugins: [
143+
replace(baseConfig.plugins.replace),
144+
...baseConfig.plugins.preVue,
145+
vue(baseConfig.plugins.vue),
146+
babel(baseConfig.plugins.babel),
147+
commonjs(),
148+
terser({
149+
output: {
150+
ecma: 5,
151+
},
152+
}),
153+
],
154+
};
155+
buildFormats.push(unpkgConfig);
156+
}
157+
158+
// Export config
159+
export default buildFormats;
File renamed without changes.

dev/serve.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Vue, { VNode } from 'vue';
2+
import Dev from './serve.vue';
3+
4+
Vue.config.productionTip = false;
5+
6+
new Vue({
7+
render: (h): VNode => h(Dev),
8+
}).$mount('#app');

dev/serve.vue

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<script lang="ts">
2+
import Vue from 'vue';
3+
import VueTyped from '@/vue-typed.vue';
4+
5+
export default Vue.extend({
6+
name: 'ServeDev',
7+
components: {
8+
VueTyped
9+
}
10+
});
11+
</script>
12+
13+
<template>
14+
<div id="app">
15+
<img alt="Vue logo" src="./assets/logo.png" />
16+
<vue-typed :tag="'h1'" :text="['VueTyped', 'vue-typed', 'vueTyped']"/>
17+
<vue-typed :tag="'p'" :text="'Welcome to Your VueTyped'" />
18+
</div>
19+
</template>
20+
21+
<style>
22+
h3 {
23+
margin: 40px 0 0;
24+
}
25+
ul {
26+
list-style-type: none;
27+
padding: 0;
28+
}
29+
li {
30+
display: inline-block;
31+
margin: 0 10px;
32+
}
33+
a {
34+
color: #42b983;
35+
}
36+
#app {
37+
font-family: Avenir, Helvetica, Arial, sans-serif;
38+
-webkit-font-smoothing: antialiased;
39+
-moz-osx-font-smoothing: grayscale;
40+
text-align: center;
41+
color: #2c3e50;
42+
margin-top: 60px;
43+
}
44+
</style>

0 commit comments

Comments
 (0)