File tree Expand file tree Collapse file tree 5 files changed +10
-20
lines changed Expand file tree Collapse file tree 5 files changed +10
-20
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ module.exports = {
15
15
ROOT : ROOT , // 项目根目录
16
16
BUILD : ROOT . join ( 'build' ) , // 构建工具配置目录
17
17
DIST : ROOT . join ( 'dist' ) , // build 后输出目录
18
+ DOCS : ROOT . join ( 'docs' ) , // 文档
18
19
MOCK : ROOT . join ( 'mock' ) , // Mock Server 目录
19
20
SRC : ROOT . join ( 'src' ) , // 源码目录
20
21
STATIC : ROOT . join ( 'static' ) // 高度静态资源目录
Original file line number Diff line number Diff line change 1
- var fs = require ( 'fs' ) ,
1
+ var fs = require ( 'fs-extra ' ) ,
2
2
webpack = require ( 'webpack' ) ,
3
3
gulp = require ( './gulpfile' ) ,
4
4
PATHS = require ( './config/PATHS' ) ,
5
5
config = require ( './webpack.prod.conf' ) ;
6
6
7
+ fs . emptyDirSync ( PATHS . DIST ) ; // 清空 build 目录
8
+ fs . copySync ( PATHS . STATIC , PATHS . DIST . join ( 'static' ) ) ; // 复制高度静态资源
9
+ fs . copySync ( PATHS . DOCS . join ( '_book' ) , PATHS . DIST . join ( 'docs' ) ) ; // 复制文档
10
+
7
11
webpack ( config , function ( err , stats ) {
8
12
// show build info to console
9
13
console . log ( stats . toString ( { chunks : false , color : true } ) ) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ var webpack = require('webpack'),
3
3
PATHS = require ( './config/PATHS' ) ,
4
4
config = require ( './webpack.base.conf' ) ,
5
5
HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ,
6
- CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ,
7
6
ExtractTextPlugin = require ( 'extract-text-webpack-plugin' ) ,
8
7
// SOURCE_MAP = true; // 大多数情况下用不到
9
8
SOURCE_MAP = false ;
@@ -25,8 +24,6 @@ config.module.loaders.push({
25
24
loader : ExtractTextPlugin . extract ( 'style' , 'css!sass' )
26
25
} ) ;
27
26
28
- fs . emptyDirSync ( PATHS . DIST ) ; // 清空 build 目录
29
-
30
27
config . plugins . push (
31
28
new webpack . optimize . DedupePlugin ( ) ,
32
29
new webpack . optimize . OccurenceOrderPlugin ( ) ,
@@ -49,21 +46,7 @@ config.plugins.push(
49
46
new HtmlWebpackPlugin ( {
50
47
filename : '../index.html' ,
51
48
template : PATHS . SRC . join ( 'index.html' )
52
- } ) ,
53
- new CopyWebpackPlugin ( [ // 复制高度静态资源
54
- {
55
- context : PATHS . STATIC ,
56
- from : '**/*' ,
57
- ignore : [ '*.md' ]
58
- }
59
- ] ) ,
60
- new CopyWebpackPlugin ( [ // 复制文档
61
- {
62
- context : PATHS . ROOT . join ( 'docs/_book' ) ,
63
- from : '**/*' ,
64
- to : '../docs/'
65
- }
66
- ] )
49
+ } )
67
50
) ;
68
51
69
52
module . exports = config ;
Original file line number Diff line number Diff line change
1
+ 本目录放置高度静态且不经由 Webpack 处理的文件
2
+ (例如需要全局引入的样式、脚本)
3
+ 其中 plugins/ 存放需要 Gulp 合并压缩打包的文件
Original file line number Diff line number Diff line change 32
32
"browser-sync" : " ^2.11.1" ,
33
33
"browser-sync-webpack-plugin" : " ^1.0.1" ,
34
34
"connect-history-api-fallback" : " ^1.1.0" ,
35
- "copy-webpack-plugin" : " ^4.0.1" ,
36
35
"cross-env" : " ^3.1.3" ,
37
36
"css-loader" : " ^0.23.0" ,
38
37
"eslint" : " ^1.10.3" ,
You can’t perform that action at this time.
0 commit comments