Skip to content

Commit da9f968

Browse files
author
罗学
committed
fix: 修复 webpack tempalte
1 parent 8cc7be0 commit da9f968

File tree

5 files changed

+107
-3
lines changed

5 files changed

+107
-3
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
},
2121
"main": "index.js",
2222
"devDependencies": {
23-
"@pkb/cli": "^1.4.21",
23+
"@pkb/cli": "^1.4.22",
2424
"@pkb/plugin-react": "^1.4.8",
2525
"@pkb/rollup-box": "^1.4.20",
26-
"@pkb/webpack-box": "^1.4.19"
26+
"@pkb/webpack-box": "^1.4.22"
2727
},
2828
"bugs": {
2929
"url": "https://github.com/luoxue-victor/learn_webpack/issues"

packages/cli/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
package-lock.json
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
}

packages/cli/template/webpack/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
{
22
"version": "0.1.0",
33
"private": true,
4+
"scripts": {
5+
"dev": "webpack-box dev",
6+
"dev:dash": "webpack-dashboard -- webpack-box dev",
7+
"build": "webpack-box build",
8+
"dev:docker": "docker run -v \"$(PWD)\":/usr/src/webpack-box/ docker-webpack-box npm run dev",
9+
"build:docker": "docker build -t docker-webpack-box ."
10+
},
411
"devDependencies": {
512
"@pkb/plugin-react": "1.4.8",
613
"@pkb/webpack-box": "1.4.19"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// 加载react
22
import React from 'react'
33
import ReactDom from 'react-dom'
4-
import { App } from './src/demo'
4+
import { App } from './demo'
55

66
ReactDom.render(<App/>, document.getElementById('app'))

0 commit comments

Comments
 (0)