Skip to content

Commit ad40622

Browse files
committed
fix sourcemap locations for bundle
1 parent 93aba94 commit ad40622

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"README.md"
1414
],
1515
"scripts": {
16-
"build": "rimraf dist/* && rollup -c",
16+
"build": "rimraf dist/* && rollup -c && node rewrite-map.js",
1717
"output": "npm run build && rimraf out/* && build-examples",
1818
"prepack": "npm run build && rimraf out/*",
1919
"start": "serve-examples",

rewrite-map.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
var fs = require('fs');
3+
4+
5+
function read(filename){
6+
return String(fs.readFileSync(filename, {encoding:'utf8'}));
7+
}
8+
9+
var file = 'dist/ax.css.map',
10+
src = JSON.parse(read(file)),
11+
pkg = JSON.parse(read('package.json'));
12+
13+
src.sources = src.sources.map(function(s){
14+
return '../datagrid@' + pkg.version + '/css/' + s;
15+
});
16+
17+
18+
fs.writeFileSync(file, JSON.stringify(src));

rollup.config.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import postcss from 'rollup-plugin-postcss';
55
import sourcemaps from 'rollup-plugin-sourcemaps';
66
import fs from 'fs';
77
import path from 'path';
8+
import rootpkg from './package.json';
89

910

1011
let name = 'ActiveWidgets.JS',
@@ -73,7 +74,11 @@ let bundles = roots.bundles.map(dir => {
7374

7475
let input = path.join(dir, 'index.js'),
7576
file = path.join('dist', (dir || 'ax') + '.js'),
76-
sourcemapPathTransform = s => s.replace('node_modules', '../..'),
77+
sourcemapPathTransform = s => {
78+
return s.replace(/^\.\../, '')
79+
.replace(/node_modules/, '..')
80+
.replace(/@activewidgets.(\w+)/, '$1@' + rootpkg.version);
81+
},
7782
sourcemap = true,
7883
compact = true;
7984

0 commit comments

Comments
 (0)