加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/wdfe/weweb
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.config.dev.js 2.58 KB
一键复制 编辑 原始数据 按行查看 历史
Junjie Ding 提交于 2017-11-21 18:03 . feat: support decode in wxml
/*
* 直接打包至 wewbTmp 目录,调试用
*/
const webpack = require('webpack')
const path = require('path')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const DIST_PATH = './wewebTmp/dist/script'
const isProd = process.env.NODE_ENV === 'production'
const showAnalysis = process.env.ANA === 'true'
const watch = process.env.WATCH === 'true'
// 将 css 从文本中提取出来,参数为资源存放的位置
let plugins = [new ExtractTextPlugin('../css/weweb.min.css')]
if (showAnalysis) {
plugins = plugins.concat([new BundleAnalyzerPlugin()])
}
if (isProd) {
plugins = plugins.concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.optimize.AggressiveMergingPlugin(), // Merge chunks
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_debugger: true,
dead_code: true,
properties: true,
evaluate: true
},
output: {
comments: false
}
}),
new webpack.optimize.ModuleConcatenationPlugin()
])
}
function getPath (rPath) {
return path.resolve(__dirname, rPath)
}
function getSourcePath (rPath) {
return getPath(`./src/${rPath}`)
}
module.exports = {
entry: {
weweb: getSourcePath('index.js')
},
output: {
filename: '[name].js',
publicPath: 'script/',
chunkFilename: '[name].wd.chunk.js',
path: getPath(DIST_PATH)
},
watch: watch,
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['env', 'stage-0']
}
},
{
test: /\.html/,
loader: 'html-loader'
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: {
loader: 'css-loader',
options: { minimize: true }
}
})
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
// 注意此处 outputPath 为输出结果的地址
'file-loader?name=[name].[ext]&publicPath=&outputPath=../images/'
// 'image-webpack-loader?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
},
{
test: /\.et/,
loader: 'ei-loader'
},
{
test: /\.json$/,
loader: 'json'
}
]
},
stats: {
modulesSort: 'size',
chunksSort: 'size',
assetsSort: 'size'
},
plugins: plugins
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化