html5 clipboard 兼容,webpack打包clipboard在页面中报错

本文介绍了一个具体的Webpack配置案例,包括入口文件设置、输出文件配置、模块加载方式配置及插件配置等内容,并针对出现的Uncaught ReferenceError: Clipboard is not defined错误提供了代码示例,适合对Webpack配置不熟悉的开发者参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

684e97adda1c8f625319b271ea831a49.png报错代码:Uncaught ReferenceError: Clipboard is not defined

var webpack=require('webpack');

var path=require('path');

var ex = require("extract-text-webpack-plugin");

var packCSS = new ex('./css/[name].min.css',{allChunks: true});

// var HtmlWebpackPlugin=require('html-webpack-plugin');

var autoprefixer = require('autoprefixer');

var UglifyJsPlugin = require('uglifyjs-webpack-plugin');

// var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); //css压缩

module.exports={

//入口文件配置

entry:{

//css入口

// style_head:"./src/style-head.js",

// style_index:"./src/style-index.js",

// style_high:"./src/style-high.js",

// style_jiu:'./src/style-jiu.js',

// style_user:'./src/style-user.js',

// style_avatar:'./src/style-avatar.js',

// style_footer:'./src/style-footer.js'

//js入口

main_index:'./src/main-index.js',

main_high:'./src/main-high.js',

main_jiu:'./src/main-jiu.js',

main_avatar:'./src/main-avatar.js',

main_highView:'./src/main-highView.js'

},

// 输出文件配置

output:{

path:path.resolve(__dirname,'build'),

filename:"[name].js",

publicPath:'../dist/' //动态背景图片地址

},

// 模块加载方式配置

module:{

loaders: [

//加载方式

{

test: /\.css$/,

loader:ex.extract("css-loader","style-loader",'postcss-loader'),

},

// 字体文件打包方式及路径

{test: /\.(eot|svg|ttf|woff|woff2)\w*/,loader: 'file-loader?publicPath=&outputPath=font/'},

// 打包图片及地址

{test: /\.(png|jpg|gif)$/, loader: 'url-loader?limit=8192'},

// SVG打包方式

{test: /\.svg/, loader: 'svg-url-loader'},

//sass和css

// {

// test: /\.(scss|sass|css)$/, // pack sass and css files

// loader: ex.extract({fallback: "style-loader", use: "css-loader!postcss-loader!sass-loader"})

// }

//js打包方式

// {test:/\.js$/,exclude:/node_modules/,loader:'babel-loader'}

// postcss

]

},

// 插件配置

plugins:[

new webpack.ProvidePlugin({

$: "jquery",

jQuery: "jquery",

"window.jQuery": "jquery"

}),

new webpack.optimize.UglifyJsPlugin(),

packCSS

]

};

请求高人指点!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值