|
| 1 | +const path = require('path') |
| 2 | +function resolve (dir) { |
| 3 | + return path.join(process.cwd(), dir) |
| 4 | +} |
| 5 | + |
| 6 | +module.exports = function (config) { |
| 7 | + /** |
| 8 | + * @param {object} dll 开启差分包 |
| 9 | + * @param {object} pages 多页面配置 通过 box run/build index 来使用 |
| 10 | + * @param {function} chainWebpack |
| 11 | + * @param {string} entry 入口 |
| 12 | + * @param {string} output 出口 |
| 13 | + * @param {string} publicPath |
| 14 | + * @param {string} port 端口 |
| 15 | + * @param {object} eslint eslint 配置 |
| 16 | + * @param {object} stylelint stylelint 配置 |
| 17 | + * @param {object} eslint eslint 配置 |
| 18 | + * @param {object} alias 配置别名 |
| 19 | + * @param {object} env 配置通用变量,可以在 node 跟 web 之间共同使用 |
| 20 | + * @param {Boolean} filenameHashing 文件名是否使用 hash,当文件发生变动的时候 filename 才会改变 |
| 21 | + * @param {Boolean} css 配置 css |
| 22 | + * @param {Boolean} mock 开启 mock |
| 23 | + */ |
| 24 | + return { |
| 25 | + pages: { |
| 26 | + index1: { |
| 27 | + entry: 'src/main.js', |
| 28 | + template: 'public/index.html', |
| 29 | + filename: 'index.html', |
| 30 | + publicPath: './', |
| 31 | + output: 'dist/index1' |
| 32 | + }, |
| 33 | + index2: { |
| 34 | + entry: 'src/main.js', |
| 35 | + template: 'public/index2.html', |
| 36 | + filename: 'index2.html', |
| 37 | + publicPath: './', |
| 38 | + output: 'dist/index2' |
| 39 | + } |
| 40 | + }, |
| 41 | + port: 9001, |
| 42 | + mock: true, |
| 43 | + env: { |
| 44 | + REACT: 'react' // 配置 react |
| 45 | + }, |
| 46 | + alias: { |
| 47 | + '@': resolve('src'), |
| 48 | + '@src': resolve('src') |
| 49 | + }, |
| 50 | + resources: { |
| 51 | + less: { |
| 52 | + patterns: [ |
| 53 | + path.resolve(__dirname, './src/global/*.less') |
| 54 | + ] |
| 55 | + }, |
| 56 | + scss: { |
| 57 | + patterns: [ |
| 58 | + path.resolve(__dirname, './src/global/*.scss') |
| 59 | + ] |
| 60 | + } |
| 61 | + }, |
| 62 | + css: { |
| 63 | + sourceMap: true, |
| 64 | + loaderOptions: { |
| 65 | + css: {}, |
| 66 | + less: { |
| 67 | + globalVars: { |
| 68 | + gray: '#ccc' |
| 69 | + } |
| 70 | + }, |
| 71 | + sass: {}, |
| 72 | + postcss: {}, |
| 73 | + stylus: {} |
| 74 | + }, |
| 75 | + isCssModule: false, // 是否对css进行模块化处理 |
| 76 | + needInlineMinification: false // 是否需要压缩css |
| 77 | + }, |
| 78 | + filenameHashing: true, |
| 79 | + eslint: { |
| 80 | + lintOnSave: true, // 开启运行时检测 |
| 81 | + extensions: ['js', 'jsx', 'vue'] // 默认 ['js', 'jsx'] |
| 82 | + }, |
| 83 | + tslint: { |
| 84 | + lintOnSave: true, // 开启运行时检测 |
| 85 | + useThreads: true |
| 86 | + }, |
| 87 | + stylelint: { |
| 88 | + lintOnSave: true // 开启运行时检测 |
| 89 | + // extensions: ['vue', 'htm', 'html', 'css', 'sss', 'less', 'scss'] |
| 90 | + }, |
| 91 | + // dll: { |
| 92 | + // venders: ['react'] |
| 93 | + // }, |
| 94 | + chainWebpack(config) {} |
| 95 | + } |
| 96 | +} |
0 commit comments