UNPKG

2.48 kBJavaScriptView Raw
1'use strict'
2
3const paths = require('./paths')
4const getEnv = require('./env')
5const { ensureSlash, camelName } = require('../libs/utils')
6const defConf = require('./default')
7const maraConf = require(paths.marauder)
8const pkgName = require(paths.packageJson).name
9const maraVersion = require(paths.ownPackageJson).version
10
11function getServedPath(publicUrl) {
12 // 强制以 / 结尾,为了兼容 publicPath: '.'
13 return publicUrl ? ensureSlash(publicUrl, true) : '/'
14}
15
16const publicPath = getServedPath(maraConf.publicPath)
17const publicDevPath = getServedPath(maraConf.publicDevPath)
18
19module.exports = {
20 // 为了防止不同文件夹下的同名资源文件冲突
21 // 资源文件不提供 hash 修改权限
22 hash: {
23 main: true,
24 chunk: true,
25 assets: true
26 },
27 version: maraVersion,
28 debug: maraConf.debug,
29 library: {
30 root: 'MyLibrary',
31 amd: pkgName,
32 commonjs: pkgName
33 },
34 assetsDir: 'static',
35 // 编译配置
36 compiler: Object.assign({}, defConf.compiler, maraConf.compiler),
37 entry: defConf.esm.entry,
38 // 通知 babel 编译 node_module 里额外的模块
39 esm: defConf.esm,
40 // 打包 dll
41 vendor: [],
42 paths: paths,
43 build: {
44 env: getEnv(publicPath.slice(0, -1)),
45 assetsPublicPath: publicPath,
46 // Run the build command with an extra argument to
47 // View the bundle analyzer report after build finishes:
48 // `npm run build --report`
49 // Set to `true` or `false` to always turn it on or off
50 bundleAnalyzerReport: process.env.npm_config_report,
51 // upload bundle use ftp
52 // `npm run build <page> --ftp [namespace]`
53 // Set to `true` or `false` to always turn it on or off
54 uploadFtp: process.env.npm_config_ftp,
55 testDeploy: process.env.npm_config_test
56 },
57 dev: {
58 env: getEnv(publicDevPath.slice(0, -1)),
59 port: defConf.dev.port,
60 assetsPublicPath: publicDevPath,
61 proxyTable: {},
62 // CSS Sourcemaps off by default because relative paths are "buggy"
63 // with this option, according to the CSS-Loader README
64 // (https://github.com/webpack/css-loader#sourcemaps)
65 // In our experience, they generally work as expected,
66 // just be aware of this issue when enabling this option.
67 cssSourceMap: false
68 },
69 ftp: Object.assign({}, defConf.ftp, maraConf.ftp),
70 ciConfig: Object.assign({}, defConf.ciConfig, maraConf.ciConfig),
71 // hybrid 项目配置,存在此属性时,将会生成 zip 包
72 hybrid: defConf.hybrid,
73 postcss: defConf.postcss
74}