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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| entry: {
main : ["babel-polyfill",'./src/main.js'],
},
output: {
libraryTarget: 'umd',
path: path.resolve(__dirname, './dist'),
//很关键 决定你打包后的静态资源是否能正确引用
publicPath: 'dist/',
filename: 'js/build.js'
},
//打包去除外部依赖
// externals: {
// 'vue': {
// root: 'Vue',
// commonjs: 'vue',
// commonjs2: 'vue',
// amd: 'vue'
// },
// 'lodash': {
// commonjs: 'lodash',
// commonjs2: 'lodash',
// amd: 'lodash',
// root: '_'
// },
// },
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
css: ExtractTextPlugin.extract({
use: 'css-loader',
fallback: 'vue-style-loader' // <- this is a dep of vue-loader, so no need to explicitly install if using npm3
})
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'url-loader',
options: {
name: "image/[name].[ext]?[hash]",
limit: 8192,
}
},
{
test: /\.(less|css)$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{loader: "css-loader"},
{loader: "less-loader"}
],
})
},
{
test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
loader: 'file-loader'
},
{
test: /\.(png|jpe?g|gif|svg)(\?\S*)?$/,
loader: 'file-loader',
query: {
name: '[name].[ext]?[hash]'
}
}
]
},
plugins: [
new ExtractTextPlugin("css/styles.css"),
new HtmlWebpackPlugin({
title : "超群网络科技有限公司",
template : "index.html",
inject: true,
hash : true
})
],
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
'vue-router$':'vue-router/dist/vue-router.common.js',
'vue-resource$':'vue-resource/dist/vue-resource.common.js',
'vuex':'vuex/dist/vuex.js',
}
},
devServer: {
historyApiFallback: true,
noInfo: true
},
performance: {
hints: false
},
//最完整的map信息 速度一般
devtool: '#source-map'
// 开发环境使用
// devtool: '#eval-source-map'
//速度最快,大型项目使用节省时间,但是js调试不方便
// devtool: '#cheap-module-source-map' |