1 Star 0 Fork 49

huawei/spriteJS

forked from 奇虎360/spriteJS 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
webpack.config.js 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
akira-cn 提交于 2018-04-10 17:54 . update build scripts
// const conf = require('./package.json')
module.exports = function (env = {}) {
const webpack = require('webpack'),
path = require('path'),
fs = require('fs')
const outputPath = path.resolve(__dirname, env.outputPath || 'dist')
const proxyPort = 9091,
plugins = [],
jsLoaders = []
if(env.production) {
// compress js in production environment
plugins.push(new webpack.optimize.UglifyJsPlugin({
output: {
comments: false, // remove all comments
},
compress: {
warnings: false,
drop_console: false,
},
}))
}
if(fs.existsSync('./.babelrc')) {
// use babel
const babelConf = JSON.parse(fs.readFileSync('.babelrc'))
jsLoaders.push({
loader: 'babel-loader',
options: babelConf,
})
}
return {
entry: './src/index.js',
output: {
filename: env.production ? 'spritejs.min.js' : 'spritejs.js',
path: outputPath,
publicPath: '/js/',
library: 'spritejs',
libraryTarget: 'umd',
},
plugins,
module: {
rules: [{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: jsLoaders,
}],
},
devServer: {
open: true,
proxy: {
'*': `http://127.0.0.1:${proxyPort}`,
},
},
// devtool: 'inline-source-map',
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/weizai118/spriteJS.git
git@gitee.com:weizai118/spriteJS.git
weizai118
spriteJS
spriteJS
master

搜索帮助