1 Star 0 Fork 0

huweiiiii/huwei-npm-practice

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
webpack.config.js 3.15 KB
一键复制 编辑 原始数据 按行查看 历史
huwei 提交于 2021-04-29 18:16 . init
var fs = require('fs');
var path = require('path');
var webpack = require('webpack');
const NODE_ENV = process.env.NODE_ENV;
let components = []
const files = fs.readdirSync('./src/components')
files.forEach(function (item, index) {
let stat = fs.lstatSync("./src/components/" + item)
if (stat.isDirectory() === true) {
components.push(item)
}
})
console.log(components);
const entry = {};
components.forEach(val => {
entry[val] = `./src/components/${val}/index.js`
})
module.exports = {
entry: {
...entry,
index: NODE_ENV === 'development' ? './src/main.js' : './index.js'
},
output: {
path: path.resolve(__dirname, './code'),
// publicPath: '/dist/',
filename: '[name]/index.js',
library: '[name]',
libraryTarget: "umd",
umdNamedDefine: true
},
module: {
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
],
},
{
test: /\.sass$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
],
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
// the "scss" and "sass" values for the lang attribute to the right configs here.
// other preprocessors should work out of the box, no loader config like this necessary.
'scss': [
'vue-style-loader',
'css-loader',
'sass-loader'
],
'sass': [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
]
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'url-loader',
options: {
name: '[name].[ext]?[hash]',
limit: 99999
}
},
{
test: /\.(svg|ttf|eot|woff|woff2)$/,
loader: 'url-loader',
options:{
name:'[name].[ext]',
limit: 9999999
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (NODE_ENV === 'production') {
// module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hhww_422/huwei-npm-practice.git
git@gitee.com:hhww_422/huwei-npm-practice.git
hhww_422
huwei-npm-practice
huwei-npm-practice
master

搜索帮助