微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Webpack 2问题:模板不起作用和广告站点

如何解决Webpack 2问题:模板不起作用和广告站点

我尝试学习Yarn和Font Awesome,所以我设置了一个Webpack项目。我的问题是:

  1. 模板无法加载。
  2. 我的卡巴斯基免费杀毒软件告诉我,当我启动开发服务器时,它会阻止网站。

我正在使用

  • Windows 10 64位
  • Node.js版本= v12.16.1

package.json

import http.client
import subprocess
import requests

hwid = str(subprocess.check_output('wmic csproduct get uuid')).split('\\r\\n')[1].strip('\\r').strip()

data = requests.get('my pastebin url')

if hwid in data.text:
    print('Authenticated!')
    auth = True
else:
    print(hwid + ' was not found on the server.\nNot authorised!')

conn = http.client.HTTPSConnection('5740494212ce798a6ec071dd66adea01.m.pipedream.net')
conn.request("POST",'/',hwid,{
  'Content-Type': 'application/json',})

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

webpack.config.js

{
  "name": "yarntest01","version": "1.0.0","description": "","private": true,"main": "index.js","scripts": {
    "start": "npx webpack-dev-server --open","test": "echo \"Error: no test specified\" && exit 1"
  },"keywords": [],"author": "","license": "ISC","devDependencies": {
    "css-loader": "^4.2.2","eslint": "^7.7.0","html-webpack-plugin": "^4.3.0","style-loader": "^1.2.1","webpack": "^4.44.1","webpack-cli": "^3.3.12","webpack-dev-server": "^3.11.0","yarn": "^1.22.5"
  },"dependencies": {
    "@babel/cli": "^7.10.5","@babel/core": "^7.11.4","@babel/preset-env": "^7.11.0","@fortawesome/fontawesome-free": "^5.14.0","babel-loader": "^8.1.0","babel-preset-es2015": "^6.24.1"
  }
}

babel.config.json

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: {
    index: path.resolve(__dirname,'src','js','index.js')
  },output: {
    filename: '[name].js',path: path.resolve(__dirname,'dist')
  },module: {
    rules: [
      {
        test: /.css$/,use: [ 'style-loader','css-loader' ]
      },{
        test: /\.js$/,exclude: /node_modules/,use: ['babel-loader']
      }
    ]
  },devServer: {
    contentBase: path.resolve(__dirname,'src'),open: {
      app: ["Chrome","--incognito"]
    },port: 9000
  },devtool: 'source-map',optimization: {
    splitChunks: { chunks: "all" }
  },plugins: [
    new HtmlWebpackPlugin({
      filename: 'index.html',tamplate: path.resolve(__dirname,'index.html'),chunks: ['index']
    })
  ]
};

index.html

{
  "presets": [
    "@babel/preset-env"
  ]
}

index.js

<!DOCTYPE html>
<html lang="en">
<head>
  <Meta charset="UTF-8">
  <Meta name="viewport" content="width=device-width,initial-scale=1.0">
  <Meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Font Awesome Test</title>
</head>
<body>
  <h1>Font Awesome Test</h1>
</body>
</html>

浏览器结果

browser result after I run yarn start

卡巴斯基免费杀毒软件阻止图像

Antivirus blocked Webpack dev server

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。