1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| //新建webpack.config.js
var webpack = require("webpack"); var path = require("path"); var ExtractTextPlugin = require("extract-text-webpack-plugin"); //单独打包插件 var TransferWebpackPlugin = require('transfer-webpack-plugin');//复制文件插件 module.exports = { devtool: false, entry: { entry: "./src/entry.js",//入口1 entry2: "./src/entry2.js"//入口2 }, output: { path: __dirname + "/dist/", filename: "[name].js" }, module: { loaders: [{ test: /\.css$/, //loader: "style-loader!css-loader?modules" loader: ExtractTextPlugin.extract("style-loader", "css-loader") }, { test: /\.(jpg|png)$/, loader: "url?limit=8192" }, { test: /\.scss$/, //loader: "style!css!sass" loader: ExtractTextPlugin.extract('style', 'css!sass') },{ test: /\.less$/, loader: "style!css!less" },{ test: /\.html$/, loader: "html?attrs=img:src img:data-src" }, { test: /\.(woff|ttf|eot|woff2)$/, loader: "file-loader"}
] },
resolve: { extension: ['', '.js', '.css','.html','.scss'], alias: { avalon: ("avalon2"), //avalon: path.join(__dirname, "./node_modules/avalon2/dist/avalon.js") jquery: ("jquery"), } }, plugins: [ new webpack.ProvidePlugin({ //将jQuery设置成全局变量 $: "jquery", jQuery: "jquery", "window.jQuery": "jquery", "window.$": "jquery" }), new ExtractTextPlugin("styles.css"), new TransferWebpackPlugin([ {from: '',to:''} ], path.resolve(__dirname,'')),//copy new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })//压缩js
] }
|