Skip to content

Commit

Permalink
fix(build): 修复了build是 publicPath 的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxue committed Nov 26, 2019
1 parent 86a0418 commit ac2ab19
Show file tree
Hide file tree
Showing 29 changed files with 42 additions and 120 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## 1.0.2 (2019-11-26)
# 1.0.0 (2019-11-26)

### 🌟 新功能

* **编译:** 提升编译速度,增加了 cache-loader dllPlugin threadLoader ([4d44ad7](https://github.com/luoxue-victor/learn_webpack/commit/4d44ad7))
* **多页面:** webpack配置多页面打包 ([86a0418](https://github.com/luoxue-victor/learn_webpack/commit/86a0418))
* **课题2:** 完成基本构建,js、css打包进html,实现dev跟build环境 ([71a6a19](https://github.com/luoxue-victor/learn_webpack/commit/71a6a19))
* **新增loader配置:** 增加ts、css、less、sass、postcss、babel配置 ([53616f8](https://github.com/luoxue-victor/learn_webpack/commit/53616f8))
* **性能优化:** 性能优化1 ([0909b33](https://github.com/luoxue-victor/learn_webpack/commit/0909b33))
Expand Down
2 changes: 1 addition & 1 deletion build/base.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { findSync } = require('../lib')
const Config = require('webpack-chain');
const config = new Config();
const files = findSync('config')
const files = findSync('../config')
const path = require('path');
const resolve = (p) => {
return path.join(process.cwd(), p)
Expand Down
17 changes: 12 additions & 5 deletions config/ForkTsChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const ForkTsCheckerNotifierWebpackPlugin = require('fork-ts-checker-notifier-webpack-plugin');

module.exports = ({ config }) => {
const chalk = require('chalk')

return () => {
config.plugin('ts-fork')
.use(ForkTsCheckerWebpackPlugin, [{
// 将async设为false,可以阻止Webpack的emit以等待类型检查器/linter,并向Webpack的编译添加错误。
async: false
}])
try {
require(resolve('tsconfig.json'))
config.plugin('ts-fork')
.use(ForkTsCheckerWebpackPlugin, [{
// 将async设为false,可以阻止Webpack的emit以等待类型检查器/linter,并向Webpack的编译添加错误。
async: false
}])
} catch (error) {
console.log(chalk.yellow('您项目中未配置 tsconfig.json,可能会影响您的静态检查报错~'))
}
// 将TypeScript类型检查错误以弹框提示
// 如果fork-ts-checker-webpack-plugin的async为false时可以不用
// 否则建议使用,以方便发现错误
Expand Down
6 changes: 3 additions & 3 deletions config/HtmlWebpackPlugin.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = ({ config, options }) => {
let template = 'public/index.html', filename = 'index.html', title = 'asdasd';
let template = 'public/index.html', filename = 'index.html';
if (options.name) {
const name = options.name;
entry = options.pages[name].template;
filename = options.pages[name].filename;
title = options.pages[name].title;
publicPath = options.pages[name].publicPath;
}
return () => {
config.plugin('html')
.use(HtmlWebpackPlugin, [{
template,
filename,
title
publicPath
}])
}
}
9 changes: 0 additions & 9 deletions config/OptionsChainLoader.js

This file was deleted.

2 changes: 2 additions & 0 deletions config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = ({ config, resolve, options }) => {
let name = 'app',
entry = options.entry || 'src/main.js',
dist = options.dist || 'dist';
publicPath = options.publicPath || '/'
if (options.name) {
name = options.name;
dist = `${dist}/${name}`
Expand All @@ -21,6 +22,7 @@ module.exports = ({ config, resolve, options }) => {
.output
.path(resolve(dist))
.filename('[name].bundle.js')
.publicPath(publicPath)

config.devtool('cheap-source-map')
}
Expand Down
23 changes: 0 additions & 23 deletions dist/index/index.bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/index/index.bundle.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/index/index.bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/index/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html><head><link href="index.css" rel="stylesheet"></head>
<html><head><link href="/common/index.css" rel="stylesheet"></head>
<head>
<meta charset="UTF-8">
<title>index page1</title>
<body><script type="text/javascript" src="manifest.bundle.js"></script><script type="text/javascript" src="chunk-vendors.bundle.js"></script><script type="text/javascript" src="index.bundle.js"></script></body>
<body><script type="text/javascript" src="/common/manifest.bundle.js"></script><script type="text/javascript" src="/common/chunk-vendors.bundle.js"></script><script type="text/javascript" src="/common/index.bundle.js"></script></body>
</html>
2 changes: 1 addition & 1 deletion dist/index/manifest.bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dist/index/manifest.bundle.js.gz
Binary file not shown.
Loading

0 comments on commit ac2ab19

Please sign in to comment.