Commit c9c5e751ae6215a99174a6e04981d8b424026b92
1 parent
c06e99d0
[change] optimize the webapack config
[change] rename test to examples
Showing
47 changed files
with
81 additions
and
128 deletions
Show diff stats
1 | +/** | |
2 | + * 公共配置 | |
3 | + */ | |
4 | +var webpack = require('webpack'); | |
5 | + | |
6 | +module.exports = { | |
7 | + // 加载器 | |
8 | + module: { | |
9 | + // https://doc.webpack-china.org/guides/migrating/#module-loaders-module-rules | |
10 | + rules: [ | |
11 | + { | |
12 | + // https://vue-loader.vuejs.org/en/configurations/extract-css.html | |
13 | + test: /\.vue$/, | |
14 | + loader: 'vue-loader', | |
15 | + options: { | |
16 | + loaders: { | |
17 | + css: 'vue-style-loader!css-loader', | |
18 | + less: 'vue-style-loader!css-loader!less-loader' | |
19 | + }, | |
20 | + postLoaders: { | |
21 | + html: 'babel-loader' | |
22 | + } | |
23 | + } | |
24 | + }, | |
25 | + { | |
26 | + test: /\.js$/, | |
27 | + loader: 'babel-loader', exclude: /node_modules/ | |
28 | + }, | |
29 | + { | |
30 | + test: /\.css$/, | |
31 | + use: [ | |
32 | + 'style-loader', | |
33 | + 'css-loader', | |
34 | + 'autoprefixer-loader' | |
35 | + ] | |
36 | + }, | |
37 | + { | |
38 | + test: /\.less$/, | |
39 | + use: [ | |
40 | + 'style-loader', | |
41 | + 'css-loader', | |
42 | + 'less-loader' | |
43 | + ] | |
44 | + }, | |
45 | + { | |
46 | + test: /\.scss$/, | |
47 | + use: [ | |
48 | + 'style-loader', | |
49 | + 'css-loader', | |
50 | + 'sass-loader?sourceMap' | |
51 | + ] | |
52 | + }, | |
53 | + { test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=8192'}, | |
54 | + { test: /\.(html|tpl)$/, loader: 'html-loader' } | |
55 | + ] | |
56 | + }, | |
57 | + resolve: { | |
58 | + extensions: ['.js', '.vue'] | |
59 | + } | |
60 | +}; | ... | ... |
build/webpack.dev.config.js
... | ... | @@ -6,109 +6,35 @@ var path = require('path'); |
6 | 6 | var webpack = require('webpack'); |
7 | 7 | // var ExtractTextPlugin = require('extract-text-webpack-plugin'); |
8 | 8 | var HtmlWebpackPlugin = require('html-webpack-plugin'); |
9 | +var merge = require('webpack-merge') | |
10 | +var webpackBaseConfig = require('./webpack.base.config.js'); | |
9 | 11 | |
10 | -module.exports = { | |
12 | + | |
13 | +module.exports = merge(webpackBaseConfig, { | |
11 | 14 | // 入口 |
12 | 15 | entry: { |
13 | - main: './test/main', | |
16 | + main: './examples/main', | |
14 | 17 | vendors: ['vue', 'vue-router'] |
15 | 18 | }, |
16 | 19 | // 输出 |
17 | 20 | output: { |
18 | - path: path.join(__dirname, '../test/dist'), | |
21 | + path: path.join(__dirname, '../examples/dist'), | |
19 | 22 | publicPath: '', |
20 | 23 | filename: '[name].js', |
21 | 24 | chunkFilename: '[name].chunk.js' |
22 | 25 | }, |
23 | - // 加载器 | |
24 | - module: { | |
25 | - // https://doc.webpack-china.org/guides/migrating/#module-loaders-module-rules | |
26 | - rules: [ | |
27 | - { | |
28 | - // https://vue-loader.vuejs.org/en/configurations/extract-css.html | |
29 | - test: /\.vue$/, | |
30 | - loader: 'vue-loader', | |
31 | - options: { | |
32 | - loaders: { | |
33 | - css: 'vue-style-loader!css-loader', | |
34 | - less: 'vue-style-loader!css-loader!less-loader' | |
35 | - }, | |
36 | - postLoaders: { | |
37 | - html: 'babel-loader' | |
38 | - } | |
39 | - } | |
40 | - }, | |
41 | - // { test: /\.vue$/, loader: 'vue' }, | |
42 | - // Module build failed: Error: The node API for `babel` has been moved to `babel-core`. | |
43 | - // https://github.com/babel/babel-loader/blob/master/README.md#the-node-api-for-babel-has-been-moved-to-babel-core | |
44 | - { | |
45 | - test: /\.js$/, | |
46 | - loader: 'babel-loader', exclude: /node_modules/ | |
47 | - }, | |
48 | - { | |
49 | - test: /\.css$/, | |
50 | - use: [ | |
51 | - 'style-loader', | |
52 | - 'css-loader', | |
53 | - 'autoprefixer-loader' | |
54 | - ] | |
55 | - }, | |
56 | - { | |
57 | - test: /\.less$/, | |
58 | - use: [ | |
59 | - 'style-loader', | |
60 | - 'css-loader', | |
61 | - 'less-loader' | |
62 | - ] | |
63 | - // loader: 'style!css!less' | |
64 | - }, | |
65 | - { | |
66 | - test: /\.scss$/, | |
67 | - use: [ | |
68 | - 'style-loader', | |
69 | - 'css-loader', | |
70 | - 'sass-loader?sourceMap' | |
71 | - ] | |
72 | - // loader: 'style!css!sass?sourceMap' | |
73 | - }, | |
74 | - { test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=8192'}, | |
75 | - { test: /\.(html|tpl)$/, loader: 'html-loader' } | |
76 | - ] | |
77 | - }, | |
78 | - // vue: { | |
79 | - // loaders: { | |
80 | - // css: ExtractTextPlugin.extract( | |
81 | - // "style-loader", | |
82 | - // "css-loader?sourceMap", | |
83 | - // { | |
84 | - // publicPath: "/test/dist/" | |
85 | - // } | |
86 | - // ), | |
87 | - // less: ExtractTextPlugin.extract( | |
88 | - // 'vue-style-loader', | |
89 | - // 'css-loader!less-loader' | |
90 | - // ), | |
91 | - // js: 'babel' | |
92 | - // } | |
93 | - // }, | |
94 | 26 | resolve: { |
95 | - // require时省略的扩展名,如:require('module') 不需要module.js | |
96 | - extensions: ['.js', '.vue'], | |
97 | 27 | alias: { |
98 | 28 | iview: '../../src/index', |
99 | 29 | vue: 'vue/dist/vue.js' |
100 | 30 | } |
101 | 31 | }, |
102 | 32 | plugins: [ |
103 | - // new ExtractTextPlugin({ filename: '[name].css', disable: false, allChunks: true }), | |
104 | - // new ExtractTextPlugin("[name].css",{ allChunks : true,resolve : ['modules'] }), // 提取CSS | |
105 | - // https://doc.webpack-china.org/plugins/commons-chunk-plugin/ | |
106 | 33 | new webpack.optimize.CommonsChunkPlugin({ name: 'vendors', filename: 'vendor.bundle.js' }), |
107 | 34 | new HtmlWebpackPlugin({ |
108 | 35 | inject: true, |
109 | - filename: path.join(__dirname, '../test/dist/index.html'), | |
110 | - template: path.join(__dirname, '../test/index.html') // 模版文件 | |
36 | + filename: path.join(__dirname, '../examples/dist/index.html'), | |
37 | + template: path.join(__dirname, '../examples/index.html') | |
111 | 38 | }) |
112 | - // new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'), // 提取第三方库 | |
113 | 39 | ] |
114 | -}; | |
40 | +}); | ... | ... |
build/webpack.dist.dev.config.js
1 | 1 | var path = require('path'); |
2 | 2 | var webpack = require('webpack'); |
3 | +var merge = require('webpack-merge') | |
4 | +var webpackBaseConfig = require('./webpack.base.config.js'); | |
3 | 5 | |
4 | -module.exports = { | |
6 | +module.exports = merge(webpackBaseConfig, { | |
5 | 7 | entry: { |
6 | 8 | main: './src/index.js' |
7 | 9 | }, |
... | ... | @@ -21,26 +23,6 @@ module.exports = { |
21 | 23 | amd: 'vue' |
22 | 24 | } |
23 | 25 | }, |
24 | - resolve: { | |
25 | - extensions: ['.js', '.vue'] | |
26 | - }, | |
27 | - module: { | |
28 | - rules: [ | |
29 | - { | |
30 | - test: /\.vue$/, | |
31 | - loader: 'vue-loader', | |
32 | - options: { | |
33 | - postLoaders: { | |
34 | - html: 'babel-loader' | |
35 | - } | |
36 | - } | |
37 | - }, | |
38 | - { | |
39 | - test: /\.js$/, | |
40 | - loader: 'babel-loader', exclude: /node_modules/ | |
41 | - } | |
42 | - ] | |
43 | - }, | |
44 | 26 | plugins: [ |
45 | 27 | new webpack.DefinePlugin({ |
46 | 28 | 'process.env': { |
... | ... | @@ -48,4 +30,4 @@ module.exports = { |
48 | 30 | } |
49 | 31 | }) |
50 | 32 | ] |
51 | -} | |
33 | +}); | ... | ... |
build/webpack.dist.prod.config.js
1 | 1 | var path = require('path'); |
2 | 2 | var webpack = require('webpack'); |
3 | +var merge = require('webpack-merge') | |
4 | +var webpackBaseConfig = require('./webpack.base.config.js'); | |
3 | 5 | |
4 | -module.exports = { | |
6 | + | |
7 | + | |
8 | +module.exports = merge(webpackBaseConfig, { | |
5 | 9 | entry: { |
6 | 10 | main: './src/index.js' |
7 | 11 | }, |
... | ... | @@ -21,26 +25,6 @@ module.exports = { |
21 | 25 | amd: 'vue' |
22 | 26 | } |
23 | 27 | }, |
24 | - resolve: { | |
25 | - extensions: ['.js', '.vue'] | |
26 | - }, | |
27 | - module: { | |
28 | - rules: [ | |
29 | - { | |
30 | - test: /\.vue$/, | |
31 | - loader: 'vue-loader', | |
32 | - options: { | |
33 | - postLoaders: { | |
34 | - html: 'babel-loader' | |
35 | - } | |
36 | - } | |
37 | - }, | |
38 | - { | |
39 | - test: /\.js$/, | |
40 | - loader: 'babel-loader', exclude: /node_modules/ | |
41 | - } | |
42 | - ] | |
43 | - }, | |
44 | 28 | plugins: [ |
45 | 29 | new webpack.DefinePlugin({ |
46 | 30 | 'process.env': { |
... | ... | @@ -53,4 +37,4 @@ module.exports = { |
53 | 37 | } |
54 | 38 | }) |
55 | 39 | ] |
56 | -} | |
40 | +}); | ... | ... |
test/app.vue renamed to examples/app.vue
test/index.html renamed to examples/index.html
test/main.js renamed to examples/main.js
test/routers/affix.vue renamed to examples/routers/affix.vue
test/routers/alert.vue renamed to examples/routers/alert.vue
test/routers/badge.vue renamed to examples/routers/badge.vue
test/routers/breadcrumb.vue renamed to examples/routers/breadcrumb.vue
test/routers/button.vue renamed to examples/routers/button.vue
test/routers/card.vue renamed to examples/routers/card.vue
test/routers/carousel.vue renamed to examples/routers/carousel.vue
test/routers/cascader.vue renamed to examples/routers/cascader.vue
test/routers/checkbox.vue renamed to examples/routers/checkbox.vue
test/routers/circle.vue renamed to examples/routers/circle.vue
test/routers/collapse.vue renamed to examples/routers/collapse.vue
test/routers/date.vue renamed to examples/routers/date.vue
test/routers/dropdown.vue renamed to examples/routers/dropdown.vue
test/routers/form.vue renamed to examples/routers/form.vue
test/routers/grid.vue renamed to examples/routers/grid.vue
test/routers/input-number.vue renamed to examples/routers/input-number.vue
test/routers/input.vue renamed to examples/routers/input.vue
test/routers/menu.vue renamed to examples/routers/menu.vue
test/routers/message.vue renamed to examples/routers/message.vue
test/routers/more.vue renamed to examples/routers/more.vue
test/routers/notice.vue renamed to examples/routers/notice.vue
test/routers/page.vue renamed to examples/routers/page.vue
test/routers/poptip.vue renamed to examples/routers/poptip.vue
test/routers/progress.vue renamed to examples/routers/progress.vue
test/routers/radio.vue renamed to examples/routers/radio.vue
test/routers/rate.vue renamed to examples/routers/rate.vue
test/routers/select.vue renamed to examples/routers/select.vue
test/routers/slider.vue renamed to examples/routers/slider.vue
test/routers/steps.vue renamed to examples/routers/steps.vue
test/routers/switch.vue renamed to examples/routers/switch.vue
test/routers/table.vue renamed to examples/routers/table.vue
test/routers/tabs.vue renamed to examples/routers/tabs.vue
test/routers/tag.vue renamed to examples/routers/tag.vue
test/routers/timeline.vue renamed to examples/routers/timeline.vue
test/routers/tooltip.vue renamed to examples/routers/tooltip.vue
test/routers/transfer.vue renamed to examples/routers/transfer.vue
test/routers/tree.vue renamed to examples/routers/tree.vue
test/routers/upload.vue renamed to examples/routers/upload.vue
package.json