当前位置: 首页 > news >正文

郑州微信网站开发如何推广宣传一个品牌

郑州微信网站开发,如何推广宣传一个品牌,扫二维码直接进入网站怎么做,营销型网站建设推广先看看我的目录结构(我全局使用TS): 一、安装配置webpack打包 安装esno npm install esnoesno 是基于 esbuild 的 TS/ESNext node 运行时,有了它,就可以直接通过esno *.ts的方式启动脚本,package.json中添加 type:…

先看看我的目录结构(我全局使用TS):
在这里插入图片描述

一、安装配置webpack打包

安装esno

npm install esno

esno 是基于 esbuild 的 TS/ESNext node 运行时,有了它,就可以直接通过esno *.ts的方式启动脚本,package.json中添加 type:“module”,使用esm的模块管理方式。

{"name": "create-my-vue-test","version": "1.0.0","main": "index.js","scripts": {"test": "echo \"Error: no test specified\" && exit 1","build": "esno ./config/build.ts"},"type": "module","keywords": [],"author": "","license": "ISC","description": "","dependencies": {"esno": "^4.0.0"}
}

创建build.ts,执行npm run build
在这里插入图片描述

安装webpack、webpack-cli

npm install webpack
npm install webpack-cli

webpack必须安装webpackcli
build.ts中编写打包代码

import webpack, { Stats } from "webpack";
import config from "./webpack.config"//我直接使用webpack,不使用webpck-cli,vue的脚手架
const compiler = webpack(config, (err, stats) => {if (err) {console.error(err.stack || err)} else if ((stats as Stats).hasErrors()) {console.log(stats);} else {}
})

编写打包配置文件webpack.config.ts

import path from "path";//nodejs里面的基本包,用来处理路径
const parentDir = path.resolve(process.cwd());//我们先打个基本的包
export default {mode: "development" as "development",entry: "./src/main.ts",output: {path: path.join(parentDir, 'dist'),filename: "bundle.js",},module: {// 指定要加载的规则rules: [],},// 模块配置:让webpack了解哪些方法可以被当作模块引入resolve: {extensions: ['.ts', '.js']},plugins: []
};

创建业务代码入口文件main.ts

let test: string = '';
console.log(test);

执行一下打包npm run build
在这里插入图片描述
报错了,说需要个loader来处理ts,我们安装ts-loader,并在webpack.config.ts中添加相关配置

npm install ts-loader
import path from "path";//nodejs里面的基本包,用来处理路径
const parentDir = path.resolve(process.cwd());//我们先打个基本的包
export default {mode: "development" as "development",entry: "./src/main.ts",output: {path: path.join(parentDir, 'dist'),filename: "bundle.js",},module: {// 指定要加载的规则rules: [{test: /\.ts$/, // 解析 tsloader: "ts-loader"}],},// 模块配置:让webpack了解哪些方法可以被当作模块引入resolve: {extensions: ['.ts', '.js']		},plugins: []
};

再次执行npm run build

在这里插入图片描述
有报错了,说没有tsconfig.json文件
创建tsconfig.ts

{"compilerOptions": {"target": "esnext","module": "esnext","strict": true,"jsx": "preserve","importHelpers": true,"moduleResolution": "node","skipLibCheck": true,"esModuleInterop": true,"allowSyntheticDefaultImports": true,"sourceMap": true,"baseUrl": ".","paths": {"@/*": ["src/*"]},"lib": ["esnext","dom","dom.iterable","scripthost"]},"include": ["src/*.ts","src/**/*.ts","src/**/*.tsx","src/**/*.vue","tests/**/*.ts","tests/**/*.tsx"],"exclude": ["node_modules"]}

再次打包,打包成功了
在这里插入图片描述
手动拷贝到index.html里面试试,运行也没有问题
在这里插入图片描述
在这里插入图片描述
安装HtmlWebpackPlugin自动拷贝打包文件到index.html中,安装CleanWebpackPlugin,自动清除dist目录,并更新webpack.config.ts

import path from "path";//nodejs里面的基本包,用来处理路径
import { CleanWebpackPlugin } from "clean-webpack-plugin";
import HtmlWebpackPlugin from 'html-webpack-plugin';
const parentDir = path.resolve(process.cwd());//我们先打个基本的包
export default {mode: "development" as "development",entry: "./src/main.ts",output: {path: path.join(parentDir, 'dist'),filename: "bundle.js",},module: {// 指定要加载的规则rules: [{test: /\.ts$/, // 解析 tsloader: "ts-loader"}],},// 模块配置:让webpack了解哪些方法可以被当作模块引入resolve: {extensions: ['.ts', '.js']},plugins: [new HtmlWebpackPlugin({title: '你好,世界',template: './public/index.html'}),new CleanWebpackPlugin()]
};

现在就可以自动将打包js文件插入到index.html中
在这里插入图片描述
增加开发服务并热更新,安装webpack-dev-server

npm install webpack-dev-server

创建dev.ts

import path from "path";//nodejs里面的基本包,用来处理路径
import webpack, { Stats } from "webpack";
import WebpackDevServer from "webpack-dev-server";
import config from "./webpack.config"const parentDir = path.resolve(process.cwd());const compiler = webpack(config)const server = new WebpackDevServer({port: 3000,static: {directory: path.join(parentDir, 'public'),},
}, compiler);const runServer = async () => {console.log('Starting server...');await server.start();
};runServer();

在package.json中增加dev的脚本

"scripts": {"build": "esno ./config/build.ts","dev": "esno ./config/dev.ts"},

执行npm run dev,就启动起来了
在这里插入图片描述

二、集成Vue

增加App.vue、更改main.ts、main.scss
App.vue

<template><div>test</div>
</template><script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({name: "App",setup() {return {};},
});
</script>

main.ts

import { createApp } from 'vue'
import App from './components/App.vue'
import "./assets/main.scss"// 注意:这里的 #app,需要在 public/index.html 中,写一个 id 为 app 的 div
createApp(App).mount('#app');

main.scss

* {background-color: red;
}

在这里插入图片描述
安装依赖

npm i --save-dev vue vue-loader url-loader style-loader css-loader node-sass sass-loader

更改webpack.config.ts

import path from "path";//nodejs里面的基本包,用来处理路径
import { CleanWebpackPlugin } from "clean-webpack-plugin";
import HtmlWebpackPlugin from 'html-webpack-plugin';
import { VueLoaderPlugin } from "vue-loader"const parentDir = path.resolve(process.cwd());//我们先打个基本的包
export default {mode: "development" as "development",entry: "./src/main.ts",output: {path: path.join(parentDir, 'dist'),filename: "bundle.js",},module: {// 指定要加载的规则rules: [{test: /\.vue$/,loader: 'vue-loader',},{test: /\.scss$/,use: ['style-loader',//https://github.com/vuejs/vue-style-loader/issues/42'css-loader','sass-loader']},{test: /\.css$/i,use: ["style-loader", "css-loader"],},{test: /\.(woff|woff2|eot|ttf|svg)$/,use: [{loader: 'url-loader',options: {limit: 10000,name: './font/[hash].[ext]',publicPath: 'dist'}}]},{test: /\.(png|jpg|gif)$/i,use: [{loader: 'url-loader',options: {limit: 8192,},},],},{test: /\.ts$/, // 解析 tsloader: "ts-loader",options: {// 上面一行不太重要,应该会按照默认路径寻找,下面一行必须要// appendTsSuffixTo/appendTsxSuffixTo配置项的意思是说,从vue文件里面分离的script的ts,tsx(取决于<script lang="xxx"></script>)内容将会被加上ts或者tsx的后缀,然后交由ts-loader解析。// 我在翻看了ts-loader上关于appendTsxSuffixTo的讨论发现,ts-loader貌似对文件后缀名称有很严格的限定,必须得是ts/tsx后缀,所以得在vue-loader extract <script>中内容后,给其加上ts/tsx的后缀名,这样ts-loader才会去处理这部分的内容。// 在Vue项目中使用TypescriptconfigFile: path.resolve(process.cwd(), 'tsconfig.json'),appendTsSuffixTo: [/\.vue$/]},}],},// 模块配置:让webpack了解哪些方法可以被当作模块引入resolve: {extensions: ['.tsx','.ts','.mjs','.js','.jsx','.vue','.json']},plugins: [new HtmlWebpackPlugin({title: '你好,世界',template: './public/index.html'}),new CleanWebpackPlugin(),// make sure to include the plugin for the magicnew VueLoaderPlugin()]
};

创建shims-vue.d.ts

/* eslint-disable */
declare module '*.vue' {import type { DefineComponent } from 'vue'const component: DefineComponent<{}, {}, any>export default component
}

最终的package.json

{"name": "create-my-vue-test","version": "1.0.0","main": "index.js","type": "module","scripts": {"test": "echo \"Error: no test specified\" && exit 1","dev": "esno ./config/dev.ts","build": "esno ./config/build.ts"},"keywords": [],"author": "","license": "ISC","description": "","dependencies": {"clean-webpack-plugin": "^4.0.0","css-loader": "^6.9.1","esno": "^4.0.0","html-webpack-plugin": "^5.6.0","node-sass": "^9.0.0","sass-loader": "^14.0.0","style-loader": "^3.3.4","ts-loader": "^9.5.1","url-loader": "^4.1.1","vue": "^3.4.15","vue-loader": "^17.4.2","webpack": "^5.89.0","webpack-cli": "^5.1.4","webpack-dev-server": "^4.15.1"}
}

再次运行,基础搭建好了
在这里插入图片描述


文章转载自:
http://marquessate.spbp.cn
http://camshaft.spbp.cn
http://unstress.spbp.cn
http://somatomedin.spbp.cn
http://opac.spbp.cn
http://cellist.spbp.cn
http://tuc.spbp.cn
http://buff.spbp.cn
http://puerilely.spbp.cn
http://pseudoscience.spbp.cn
http://penological.spbp.cn
http://transportable.spbp.cn
http://explorative.spbp.cn
http://igbo.spbp.cn
http://fenian.spbp.cn
http://patroclinous.spbp.cn
http://held.spbp.cn
http://dement.spbp.cn
http://autosave.spbp.cn
http://clemmie.spbp.cn
http://anathematically.spbp.cn
http://despoilment.spbp.cn
http://feudal.spbp.cn
http://unsympathetic.spbp.cn
http://overlord.spbp.cn
http://ostend.spbp.cn
http://hydrolysis.spbp.cn
http://exaction.spbp.cn
http://unscripted.spbp.cn
http://figurable.spbp.cn
http://nicotinamide.spbp.cn
http://paraleipsis.spbp.cn
http://orthognathous.spbp.cn
http://mack.spbp.cn
http://completeness.spbp.cn
http://pharyngeal.spbp.cn
http://cloverleaf.spbp.cn
http://rigorous.spbp.cn
http://tatami.spbp.cn
http://aural.spbp.cn
http://stapes.spbp.cn
http://diabetes.spbp.cn
http://convolute.spbp.cn
http://knotty.spbp.cn
http://roentgenise.spbp.cn
http://roadmanship.spbp.cn
http://indigen.spbp.cn
http://disunite.spbp.cn
http://adamite.spbp.cn
http://naiad.spbp.cn
http://hidrotic.spbp.cn
http://literalism.spbp.cn
http://epizoon.spbp.cn
http://undeceive.spbp.cn
http://respectively.spbp.cn
http://mesomorphy.spbp.cn
http://pity.spbp.cn
http://farrandly.spbp.cn
http://quadruped.spbp.cn
http://odovacar.spbp.cn
http://reminiscential.spbp.cn
http://bildungsroman.spbp.cn
http://persiennes.spbp.cn
http://kyte.spbp.cn
http://nonacquaintance.spbp.cn
http://xtra.spbp.cn
http://brushhook.spbp.cn
http://vortiginous.spbp.cn
http://deactivate.spbp.cn
http://bacteriological.spbp.cn
http://opal.spbp.cn
http://chauncey.spbp.cn
http://dislikeable.spbp.cn
http://pgup.spbp.cn
http://potpourri.spbp.cn
http://gesellschaft.spbp.cn
http://smb.spbp.cn
http://gaia.spbp.cn
http://zoosporangium.spbp.cn
http://milling.spbp.cn
http://corporativism.spbp.cn
http://voicelessly.spbp.cn
http://fabricate.spbp.cn
http://candour.spbp.cn
http://wineshop.spbp.cn
http://panivorous.spbp.cn
http://counterpoint.spbp.cn
http://intendment.spbp.cn
http://kerala.spbp.cn
http://calciphylaxis.spbp.cn
http://pinken.spbp.cn
http://jeopardous.spbp.cn
http://expunction.spbp.cn
http://outgrowth.spbp.cn
http://oophore.spbp.cn
http://retractible.spbp.cn
http://irrealizable.spbp.cn
http://exoterical.spbp.cn
http://varuna.spbp.cn
http://cauterant.spbp.cn
http://www.hrbkazy.com/news/81360.html

相关文章:

  • wordpress用户上传资源验证码北京seo公司有哪些
  • 江苏国税网站电子申报怎么做seo优化官网
  • 福州市网站建设有限公司重庆网站seo服务
  • 支付宝接口 网站备案seo刷关键词排名优化
  • 常州外贸网站设计营销软文范例大全100
  • 网站建设技术方面论文西安搜索引擎优化
  • 知科网站百度推广产品有哪些
  • github怎么做网站的空间软文案例200字
  • 椒江建设网保障性阳光工程网站关键词seo报价
  • 网络规划设计师攻略武汉seo网站推广
  • 腾讯域名怎么建设网站seo关键词排名优化教程
  • 坪地网站建设包括哪些百度服务
  • 给客户做网站图片侵权html简单网页代码
  • 古典lash网站带后台源码下载河北网站建设制作
  • 长沙市人民政府太原seo
  • 优惠网站怎么做搜索引擎营销
  • 建设网站团队广州百度网站快速排名
  • 昆山推广用什么网站比较好郑州seo技术培训班
  • 有没有专门做针织衫的网站游戏推广赚佣金平台
  • 网络促销的方法有哪些阿里seo排名优化软件
  • 重庆网站建设公司有哪些内容网络推广的方式
  • b2c电子商务网站制作潍坊网站收录
  • 网站开发软件手机版cba最新积分榜
  • 建筑资质证书查询网站石家庄疫情最新情况
  • 南昌市公司网站建设站长工具爱站网
  • 贵阳网站建开发如何制作app软件
  • 网站关键词优化排名推荐网站优化培训班
  • 重庆永川网站建设友情链接有哪些
  • 成都网站建设开发杭州做百度推广的公司
  • 网站开发培训内容aso排名服务公司