var path = require('path')
var HTMLWebpackPlugin = require('html-webpack-plugin')
var { CleanWebpackPlugin } = require('clean-webpack-plugin')
module.exports = {
entry: {
index: './src/index.js'
},
mode: 'development',
devtool: 'source-map',
output: {
path: path.resolve(__dirname, './dist'),
filename: "[name].js"
},
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.(png|svg)$/,
use: [
'file-loader'
]
}
]
},
plugins: [
new CleanWebpackPlugin(),
new HTMLWebpackPlugin({
title: 'My Title'
})
]
}
import './index.css'
import comp from './comp.js'
import policy from './报警地址.png'
import location from './icon-定位.svg'
var img = new Image()
img.src = policy
document.body.appendChild(img)
var imgLocation = new Image()
imgLocation.src = location
document.body.appendChild(imgLocation)
document.body.appendChild(comp())
export default function comp () {
var ele = document.createElement('div')
ele.innerHTML = 'hello webpack'
return ele
}