Commit a0382e226946405bf71ba8a69eac8d01c579e3e4
Committed by
GitHub
Merge pull request #3098 from Xotic750/enable_sourcemaps
Enable creation of sourcemaps
Showing
6 changed files
with
187 additions
and
109 deletions
Show diff stats
build/webpack.base.config.js
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | */ | 3 | */ |
4 | const path = require('path'); | 4 | const path = require('path'); |
5 | const webpack = require('webpack'); | 5 | const webpack = require('webpack'); |
6 | -const package = require('../package.json'); | 6 | +const pkg = require('../package.json'); |
7 | 7 | ||
8 | function resolve (dir) { | 8 | function resolve (dir) { |
9 | return path.join(__dirname, '..', dir); | 9 | return path.join(__dirname, '..', dir); |
@@ -20,44 +20,119 @@ module.exports = { | @@ -20,44 +20,119 @@ module.exports = { | ||
20 | loader: 'vue-loader', | 20 | loader: 'vue-loader', |
21 | options: { | 21 | options: { |
22 | loaders: { | 22 | loaders: { |
23 | - css: 'vue-style-loader!css-loader', | ||
24 | - less: 'vue-style-loader!css-loader!less-loader' | 23 | + css: [ |
24 | + 'vue-style-loader', | ||
25 | + { | ||
26 | + loader: 'css-loader', | ||
27 | + options: { | ||
28 | + sourceMap: true, | ||
29 | + }, | ||
30 | + }, | ||
31 | + ], | ||
32 | + less: [ | ||
33 | + 'vue-style-loader', | ||
34 | + { | ||
35 | + loader: 'css-loader', | ||
36 | + options: { | ||
37 | + sourceMap: true, | ||
38 | + }, | ||
39 | + }, | ||
40 | + { | ||
41 | + loader: 'less-loader', | ||
42 | + options: { | ||
43 | + sourceMap: true, | ||
44 | + }, | ||
45 | + }, | ||
46 | + ], | ||
25 | }, | 47 | }, |
26 | postLoaders: { | 48 | postLoaders: { |
27 | - html: 'babel-loader' | ||
28 | - } | 49 | + html: 'babel-loader?sourceMap' |
50 | + }, | ||
51 | + sourceMap: true, | ||
29 | } | 52 | } |
30 | }, | 53 | }, |
31 | { | 54 | { |
32 | test: /\.js$/, | 55 | test: /\.js$/, |
33 | - loader: 'babel-loader', exclude: /node_modules/ | 56 | + loader: 'babel-loader', |
57 | + options: { | ||
58 | + sourceMap: true, | ||
59 | + }, | ||
60 | + exclude: /node_modules/, | ||
34 | }, | 61 | }, |
35 | { | 62 | { |
36 | test: /\.css$/, | 63 | test: /\.css$/, |
37 | - use: [ | ||
38 | - 'style-loader', | ||
39 | - 'css-loader', | ||
40 | - 'autoprefixer-loader' | 64 | + loaders: [ |
65 | + { | ||
66 | + loader: 'style-loader', | ||
67 | + options: { | ||
68 | + sourceMap: true, | ||
69 | + }, | ||
70 | + }, | ||
71 | + { | ||
72 | + loader: 'css-loader', | ||
73 | + options: { | ||
74 | + sourceMap: true, | ||
75 | + }, | ||
76 | + }, | ||
77 | + { | ||
78 | + loader: '\'autoprefixer-loader\'', | ||
79 | + }, | ||
41 | ] | 80 | ] |
42 | }, | 81 | }, |
43 | { | 82 | { |
44 | test: /\.less$/, | 83 | test: /\.less$/, |
45 | - use: [ | ||
46 | - 'style-loader', | ||
47 | - 'css-loader', | ||
48 | - 'less-loader' | 84 | + loaders: [ |
85 | + { | ||
86 | + loader: 'style-loader', | ||
87 | + options: { | ||
88 | + sourceMap: true, | ||
89 | + }, | ||
90 | + }, | ||
91 | + { | ||
92 | + loader: 'css-loader', | ||
93 | + options: { | ||
94 | + sourceMap: true, | ||
95 | + }, | ||
96 | + }, | ||
97 | + { | ||
98 | + loader: 'less-loader', | ||
99 | + options: { | ||
100 | + sourceMap: true, | ||
101 | + }, | ||
102 | + }, | ||
49 | ] | 103 | ] |
50 | }, | 104 | }, |
51 | { | 105 | { |
52 | test: /\.scss$/, | 106 | test: /\.scss$/, |
53 | - use: [ | ||
54 | - 'style-loader', | ||
55 | - 'css-loader', | ||
56 | - 'sass-loader?sourceMap' | 107 | + loaders: [ |
108 | + { | ||
109 | + loader: 'style-loader', | ||
110 | + options: { | ||
111 | + sourceMap: true, | ||
112 | + }, | ||
113 | + }, | ||
114 | + { | ||
115 | + loader: 'css-loader', | ||
116 | + options: { | ||
117 | + sourceMap: true, | ||
118 | + }, | ||
119 | + }, | ||
120 | + { | ||
121 | + loader: 'sass-loader', | ||
122 | + options: { | ||
123 | + sourceMap: true, | ||
124 | + }, | ||
125 | + }, | ||
57 | ] | 126 | ] |
58 | }, | 127 | }, |
59 | - { test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=8192'}, | ||
60 | - { test: /\.(html|tpl)$/, loader: 'html-loader' } | 128 | + { |
129 | + test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, | ||
130 | + loader: 'url-loader?limit=8192' | ||
131 | + }, | ||
132 | + { | ||
133 | + test: /\.(html|tpl)$/, | ||
134 | + loader: 'html-loader' | ||
135 | + } | ||
61 | ] | 136 | ] |
62 | }, | 137 | }, |
63 | resolve: { | 138 | resolve: { |
@@ -70,7 +145,7 @@ module.exports = { | @@ -70,7 +145,7 @@ module.exports = { | ||
70 | plugins: [ | 145 | plugins: [ |
71 | new webpack.optimize.ModuleConcatenationPlugin(), | 146 | new webpack.optimize.ModuleConcatenationPlugin(), |
72 | new webpack.DefinePlugin({ | 147 | new webpack.DefinePlugin({ |
73 | - 'process.env.VERSION': `'${package.version}'` | 148 | + 'process.env.VERSION': `'${pkg.version}'` |
74 | }), | 149 | }), |
75 | ] | 150 | ] |
76 | }; | 151 | }; |
build/webpack.dev.config.js
@@ -12,6 +12,8 @@ const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin'); | @@ -12,6 +12,8 @@ const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin'); | ||
12 | 12 | ||
13 | 13 | ||
14 | module.exports = merge(webpackBaseConfig, { | 14 | module.exports = merge(webpackBaseConfig, { |
15 | + devtool: 'eval-source-map', | ||
16 | + | ||
15 | // ๅ ฅๅฃ | 17 | // ๅ ฅๅฃ |
16 | entry: { | 18 | entry: { |
17 | main: './examples/main', | 19 | main: './examples/main', |
build/webpack.dist.dev.config.js
1 | -const path = require('path'); | ||
2 | -const webpack = require('webpack'); | ||
3 | -const merge = require('webpack-merge'); | ||
4 | -const webpackBaseConfig = require('./webpack.base.config.js'); | ||
5 | - | ||
6 | -process.env.NODE_ENV = 'production'; | ||
7 | - | ||
8 | -module.exports = merge(webpackBaseConfig, { | ||
9 | - entry: { | ||
10 | - main: './src/index.js' | ||
11 | - }, | ||
12 | - output: { | ||
13 | - path: path.resolve(__dirname, '../dist'), | ||
14 | - publicPath: '/dist/', | ||
15 | - filename: 'iview.js', | ||
16 | - library: 'iview', | ||
17 | - libraryTarget: 'umd', | ||
18 | - umdNamedDefine: true | ||
19 | - }, | ||
20 | - externals: { | ||
21 | - vue: { | ||
22 | - root: 'Vue', | ||
23 | - commonjs: 'vue', | ||
24 | - commonjs2: 'vue', | ||
25 | - amd: 'vue' | ||
26 | - } | ||
27 | - }, | ||
28 | - plugins: [ | ||
29 | - // @todo | ||
30 | - new webpack.DefinePlugin({ | ||
31 | - 'process.env': { | ||
32 | - NODE_ENV: '"production"' | ||
33 | - } | ||
34 | - }) | ||
35 | - ] | ||
36 | -}); | 1 | +const path = require('path'); |
2 | +const webpack = require('webpack'); | ||
3 | +const merge = require('webpack-merge'); | ||
4 | +const webpackBaseConfig = require('./webpack.base.config.js'); | ||
5 | + | ||
6 | +process.env.NODE_ENV = 'production'; | ||
7 | + | ||
8 | +module.exports = merge(webpackBaseConfig, { | ||
9 | + devtool: 'eval-source-map', | ||
10 | + | ||
11 | + entry: { | ||
12 | + main: './src/index.js' | ||
13 | + }, | ||
14 | + output: { | ||
15 | + path: path.resolve(__dirname, '../dist'), | ||
16 | + publicPath: '/dist/', | ||
17 | + filename: 'iview.js', | ||
18 | + library: 'iview', | ||
19 | + libraryTarget: 'umd', | ||
20 | + umdNamedDefine: true | ||
21 | + }, | ||
22 | + externals: { | ||
23 | + vue: { | ||
24 | + root: 'Vue', | ||
25 | + commonjs: 'vue', | ||
26 | + commonjs2: 'vue', | ||
27 | + amd: 'vue' | ||
28 | + } | ||
29 | + }, | ||
30 | + plugins: [ | ||
31 | + // @todo | ||
32 | + new webpack.DefinePlugin({ | ||
33 | + 'process.env': { | ||
34 | + NODE_ENV: '"production"' | ||
35 | + } | ||
36 | + }) | ||
37 | + ] | ||
38 | +}); |
build/webpack.dist.locale.config.js
@@ -4,6 +4,7 @@ const entry = require('./locale'); | @@ -4,6 +4,7 @@ const entry = require('./locale'); | ||
4 | process.env.NODE_ENV = 'production'; | 4 | process.env.NODE_ENV = 'production'; |
5 | 5 | ||
6 | module.exports = { | 6 | module.exports = { |
7 | + devtool: 'source-map', | ||
7 | entry, | 8 | entry, |
8 | module: { | 9 | module: { |
9 | rules: [ | 10 | rules: [ |
@@ -37,9 +38,8 @@ module.exports = { | @@ -37,9 +38,8 @@ module.exports = { | ||
37 | } | 38 | } |
38 | }), | 39 | }), |
39 | new webpack.optimize.UglifyJsPlugin({ | 40 | new webpack.optimize.UglifyJsPlugin({ |
40 | - compress: { | ||
41 | - warnings: false | ||
42 | - } | 41 | + parallel: true, |
42 | + sourceMap: true, | ||
43 | }) | 43 | }) |
44 | ] | 44 | ] |
45 | }; | 45 | }; |
build/webpack.dist.prod.config.js
1 | -const path = require('path'); | ||
2 | -const webpack = require('webpack'); | ||
3 | -const merge = require('webpack-merge'); | ||
4 | -const webpackBaseConfig = require('./webpack.base.config.js'); | ||
5 | -const CompressionPlugin = require('compression-webpack-plugin'); | ||
6 | - | ||
7 | -process.env.NODE_ENV = 'production'; | ||
8 | - | ||
9 | -module.exports = merge(webpackBaseConfig, { | ||
10 | - entry: { | ||
11 | - main: './src/index.js' | ||
12 | - }, | ||
13 | - output: { | ||
14 | - path: path.resolve(__dirname, '../dist'), | ||
15 | - publicPath: '/dist/', | ||
16 | - filename: 'iview.min.js', | ||
17 | - library: 'iview', | ||
18 | - libraryTarget: 'umd', | ||
19 | - umdNamedDefine: true | ||
20 | - }, | ||
21 | - externals: { | ||
22 | - vue: { | ||
23 | - root: 'Vue', | ||
24 | - commonjs: 'vue', | ||
25 | - commonjs2: 'vue', | ||
26 | - amd: 'vue' | ||
27 | - } | ||
28 | - }, | ||
29 | - plugins: [ | ||
30 | - // @todo | ||
31 | - new webpack.DefinePlugin({ | ||
32 | - 'process.env.NODE_ENV': '"production"' | ||
33 | - }), | ||
34 | - new webpack.optimize.UglifyJsPlugin({ | ||
35 | - compress: { | ||
36 | - warnings: false | ||
37 | - } | ||
38 | - }), | ||
39 | - new CompressionPlugin({ | ||
40 | - asset: '[path].gz[query]', | ||
41 | - algorithm: 'gzip', | ||
42 | - test: /\.(js|css)$/, | ||
43 | - threshold: 10240, | ||
44 | - minRatio: 0.8 | ||
45 | - }) | ||
46 | - ] | ||
47 | -}); | 1 | +const path = require('path'); |
2 | +const webpack = require('webpack'); | ||
3 | +const merge = require('webpack-merge'); | ||
4 | +const webpackBaseConfig = require('./webpack.base.config.js'); | ||
5 | +const CompressionPlugin = require('compression-webpack-plugin'); | ||
6 | + | ||
7 | +process.env.NODE_ENV = 'production'; | ||
8 | + | ||
9 | +module.exports = merge(webpackBaseConfig, { | ||
10 | + devtool: 'source-map', | ||
11 | + entry: { | ||
12 | + main: './src/index.js' | ||
13 | + }, | ||
14 | + output: { | ||
15 | + path: path.resolve(__dirname, '../dist'), | ||
16 | + publicPath: '/dist/', | ||
17 | + filename: 'iview.min.js', | ||
18 | + library: 'iview', | ||
19 | + libraryTarget: 'umd', | ||
20 | + umdNamedDefine: true | ||
21 | + }, | ||
22 | + externals: { | ||
23 | + vue: { | ||
24 | + root: 'Vue', | ||
25 | + commonjs: 'vue', | ||
26 | + commonjs2: 'vue', | ||
27 | + amd: 'vue' | ||
28 | + } | ||
29 | + }, | ||
30 | + plugins: [ | ||
31 | + // @todo | ||
32 | + new webpack.DefinePlugin({ | ||
33 | + 'process.env.NODE_ENV': '"production"' | ||
34 | + }), | ||
35 | + new webpack.optimize.UglifyJsPlugin({ | ||
36 | + parallel: true, | ||
37 | + sourceMap: true, | ||
38 | + }), | ||
39 | + new CompressionPlugin({ | ||
40 | + asset: '[path].gz[query]', | ||
41 | + algorithm: 'gzip', | ||
42 | + test: /\.(js|css)$/, | ||
43 | + threshold: 10240, | ||
44 | + minRatio: 0.8 | ||
45 | + }) | ||
46 | + ] | ||
47 | +}); |
build/webpack.test.config.js
@@ -8,8 +8,7 @@ const webpackBaseConfig = require('./webpack.base.config.js'); | @@ -8,8 +8,7 @@ const webpackBaseConfig = require('./webpack.base.config.js'); | ||
8 | 8 | ||
9 | 9 | ||
10 | const webpackConfig = merge(webpackBaseConfig, { | 10 | const webpackConfig = merge(webpackBaseConfig, { |
11 | - // use inline sourcemap for karma-sourcemap-loader | ||
12 | - devtool: '#inline-source-map', | 11 | + devtool: 'eval-source-map', |
13 | plugins: [ | 12 | plugins: [ |
14 | new webpack.DefinePlugin({ | 13 | new webpack.DefinePlugin({ |
15 | 'process.env': { | 14 | 'process.env': { |