Enable creation of sourcemaps

This commit is contained in:
Graham Fairweather 2018-03-05 13:19:27 +01:00
parent c365be4633
commit 71eb889f6b
6 changed files with 187 additions and 109 deletions

View file

@ -3,7 +3,7 @@
*/
const path = require('path');
const webpack = require('webpack');
const package = require('../package.json');
const pkg = require('../package.json');
function resolve (dir) {
return path.join(__dirname, '..', dir);
@ -20,44 +20,119 @@ module.exports = {
loader: 'vue-loader',
options: {
loaders: {
css: 'vue-style-loader!css-loader',
less: 'vue-style-loader!css-loader!less-loader'
css: [
'vue-style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
],
less: [
'vue-style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
{
loader: 'less-loader',
options: {
sourceMap: true,
},
},
],
},
postLoaders: {
html: 'babel-loader'
}
html: 'babel-loader?sourceMap'
},
sourceMap: true,
}
},
{
test: /\.js$/,
loader: 'babel-loader', exclude: /node_modules/
loader: 'babel-loader',
options: {
sourceMap: true,
},
exclude: /node_modules/,
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
'autoprefixer-loader'
loaders: [
{
loader: 'style-loader',
options: {
sourceMap: true,
},
},
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
{
loader: '\'autoprefixer-loader\'',
},
]
},
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
'less-loader'
loaders: [
{
loader: 'style-loader',
options: {
sourceMap: true,
},
},
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
{
loader: 'less-loader',
options: {
sourceMap: true,
},
},
]
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader?sourceMap'
loaders: [
{
loader: 'style-loader',
options: {
sourceMap: true,
},
},
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
]
},
{ test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=8192'},
{ test: /\.(html|tpl)$/, loader: 'html-loader' }
{
test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
loader: 'url-loader?limit=8192'
},
{
test: /\.(html|tpl)$/,
loader: 'html-loader'
}
]
},
resolve: {
@ -70,7 +145,7 @@ module.exports = {
plugins: [
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.DefinePlugin({
'process.env.VERSION': `'${package.version}'`
'process.env.VERSION': `'${pkg.version}'`
}),
]
};

View file

@ -12,6 +12,8 @@ const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
module.exports = merge(webpackBaseConfig, {
devtool: 'eval-source-map',
// 入口
entry: {
main: './examples/main',

View file

@ -1,36 +1,38 @@
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const webpackBaseConfig = require('./webpack.base.config.js');
process.env.NODE_ENV = 'production';
module.exports = merge(webpackBaseConfig, {
entry: {
main: './src/index.js'
},
output: {
path: path.resolve(__dirname, '../dist'),
publicPath: '/dist/',
filename: 'iview.js',
library: 'iview',
libraryTarget: 'umd',
umdNamedDefine: true
},
externals: {
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
},
plugins: [
// @todo
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
})
]
});
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const webpackBaseConfig = require('./webpack.base.config.js');
process.env.NODE_ENV = 'production';
module.exports = merge(webpackBaseConfig, {
devtool: 'eval-source-map',
entry: {
main: './src/index.js'
},
output: {
path: path.resolve(__dirname, '../dist'),
publicPath: '/dist/',
filename: 'iview.js',
library: 'iview',
libraryTarget: 'umd',
umdNamedDefine: true
},
externals: {
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
},
plugins: [
// @todo
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
})
]
});

View file

@ -4,6 +4,7 @@ const entry = require('./locale');
process.env.NODE_ENV = 'production';
module.exports = {
devtool: 'source-map',
entry,
module: {
rules: [
@ -37,9 +38,8 @@ module.exports = {
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
parallel: true,
sourceMap: true,
})
]
};

View file

@ -1,47 +1,47 @@
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const webpackBaseConfig = require('./webpack.base.config.js');
const CompressionPlugin = require('compression-webpack-plugin');
process.env.NODE_ENV = 'production';
module.exports = merge(webpackBaseConfig, {
entry: {
main: './src/index.js'
},
output: {
path: path.resolve(__dirname, '../dist'),
publicPath: '/dist/',
filename: 'iview.min.js',
library: 'iview',
libraryTarget: 'umd',
umdNamedDefine: true
},
externals: {
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
},
plugins: [
// @todo
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.(js|css)$/,
threshold: 10240,
minRatio: 0.8
})
]
});
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const webpackBaseConfig = require('./webpack.base.config.js');
const CompressionPlugin = require('compression-webpack-plugin');
process.env.NODE_ENV = 'production';
module.exports = merge(webpackBaseConfig, {
devtool: 'source-map',
entry: {
main: './src/index.js'
},
output: {
path: path.resolve(__dirname, '../dist'),
publicPath: '/dist/',
filename: 'iview.min.js',
library: 'iview',
libraryTarget: 'umd',
umdNamedDefine: true
},
externals: {
vue: {
root: 'Vue',
commonjs: 'vue',
commonjs2: 'vue',
amd: 'vue'
}
},
plugins: [
// @todo
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"'
}),
new webpack.optimize.UglifyJsPlugin({
parallel: true,
sourceMap: true,
}),
new CompressionPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: /\.(js|css)$/,
threshold: 10240,
minRatio: 0.8
})
]
});

View file

@ -8,8 +8,7 @@ const webpackBaseConfig = require('./webpack.base.config.js');
const webpackConfig = merge(webpackBaseConfig, {
// use inline sourcemap for karma-sourcemap-loader
devtool: '#inline-source-map',
devtool: 'eval-source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': {