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 = {
1515 ROOT : ROOT , // 项目根目录
1616 BUILD : ROOT . join ( 'build' ) , // 构建工具配置目录
1717 DIST : ROOT . join ( 'dist' ) , // build 后输出目录
18+ DOCS : ROOT . join ( 'docs' ) , // 文档
1819 MOCK : ROOT . join ( 'mock' ) , // Mock Server 目录
1920 SRC : ROOT . join ( 'src' ) , // 源码目录
2021 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 ' ) ,
22 webpack = require ( 'webpack' ) ,
33 gulp = require ( './gulpfile' ) ,
44 PATHS = require ( './config/PATHS' ) ,
55 config = require ( './webpack.prod.conf' ) ;
66
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+
711webpack ( config , function ( err , stats ) {
812 // show build info to console
913 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'),
33 PATHS = require ( './config/PATHS' ) ,
44 config = require ( './webpack.base.conf' ) ,
55 HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ,
6- CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ,
76 ExtractTextPlugin = require ( 'extract-text-webpack-plugin' ) ,
87 // SOURCE_MAP = true; // 大多数情况下用不到
98 SOURCE_MAP = false ;
@@ -25,8 +24,6 @@ config.module.loaders.push({
2524 loader : ExtractTextPlugin . extract ( 'style' , 'css!sass' )
2625} ) ;
2726
28- fs . emptyDirSync ( PATHS . DIST ) ; // 清空 build 目录
29-
3027config . plugins . push (
3128 new webpack . optimize . DedupePlugin ( ) ,
3229 new webpack . optimize . OccurenceOrderPlugin ( ) ,
@@ -49,21 +46,7 @@ config.plugins.push(
4946 new HtmlWebpackPlugin ( {
5047 filename : '../index.html' ,
5148 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+ } )
6750) ;
6851
6952module . 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 3232 "browser-sync" : " ^2.11.1" ,
3333 "browser-sync-webpack-plugin" : " ^1.0.1" ,
3434 "connect-history-api-fallback" : " ^1.1.0" ,
35- "copy-webpack-plugin" : " ^4.0.1" ,
3635 "cross-env" : " ^3.1.3" ,
3736 "css-loader" : " ^0.23.0" ,
3837 "eslint" : " ^1.10.3" ,
You can’t perform that action at this time.
0 commit comments