加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.config.js 2.14 KB
一键复制 编辑 原始数据 按行查看 历史
tomJason 提交于 2017-10-18 17:59 . '代码分离'
const path = require('path');
const glog = require('glob');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
// const webpack = require('webpack');
module.exports = {
entry: {
index:'./src/index.js',
print:'./src/print.js',
another:'./src/another.js'
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
// publicPath:'/'
},
devtool: 'inline-source-map',
devServer: {
contentBase: './dist',
compress: true,
port: 9000,
// clientLogLevel: "none",
compress: true,
// hot: true
},
module: {
rules: [
// {
// test:/\.css$/,
// use:[
// 'style-loader',
// 'css-loader'
// ]
// },
{
test:/\.css$/,
use:ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
//如果需要,可以在 sass-loader 之前将 resolve-url-loader 链接进来
use: ['css-loader', 'sass-loader']
})
},
{
test:/\.(png|jp[e]*g|gif)$/,
use:[
{
loader:'url-loader',
options: {
name:'[name].[ext]',
limit:8000,
outputPath: 'imgaes/'
}
}
]
},
{
test: /\.(woff|woff2|eot|ttf|otf|svg)$/,
use: [
{
loader:'file-loader',
options: {
name:'[name].[ext]',
outputPath: 'font/'
}
}
]
}
]
},
plugins: [
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
title: '输出管理'
}),
new ExtractTextPlugin({
filename: '[name].css'
}),
new UglifyJSPlugin()
// 单页面程序才用模块热替换
// new webpack.HotModuleReplacementPlugin(),
]
};
function getEntries (){
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化