Skip to content

Commit

Permalink
Merge pull request #9 from caleblloyd/master
Browse files Browse the repository at this point in the history
Use webpack output.publicPath configuration
  • Loading branch information
aitoroses authored Dec 11, 2016
2 parents d9880bd + b222e44 commit 3bb5598
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,14 @@ module.exports = function () {
try {
options = JSON.parse(_fs2.default.readFileSync(_path2.default.resolve(process.cwd(), '.babelrc'), 'utf-8'));
} catch (e) {
options = { compact: false };
options = { compact: false, presets: ['es2015'] };
}
return options;
}();

// babelCode :: String -> String


babelCode = function babelCode(content) {
return es6 ? babel.transform(content, babelRc).code : content;
};
Expand Down Expand Up @@ -351,12 +352,12 @@ module.exports = function () {
// finalUrl :: String


finalUrl = (query.base || '') + '/' + pathname('[name].[ext]');
finalUrl = (query.base ? query.base + '/' : '') + pathname('[name].[ext]');

// webpackModuleResult :: String -> String

webpackModuleResult = function webpackModuleResult(url) {
return ['\t\t\t', 'var link = document.createElement(\'link\');', 'link.rel = \'import\';', 'link.href = ' + JSON.stringify(finalUrl) + ';', 'document.head.appendChild(link)'].join('\n\t\t\t');
return ['\t\t\t', 'var link = document.createElement(\'link\');', 'link.rel = \'import\';', 'link.href = __webpack_public_path__ + ' + JSON.stringify(finalUrl) + ';', 'document.head.appendChild(link)'].join('\n\t\t\t');
};

// ---------------------
Expand Down
6 changes: 3 additions & 3 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module.exports = async function main(content) {
try {
options = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), '.babelrc'), 'utf-8'))
} catch(e) {
options = {compact: false}
options = {compact: false, presets: ['es2015']}
}
return options
})()
Expand Down Expand Up @@ -162,15 +162,15 @@ module.exports = async function main(content) {
}

// finalUrl :: String
const finalUrl = (query.base || '') + '/' + pathname('[name].[ext]')
const finalUrl = (query.base ? query.base + '/' : '') + pathname('[name].[ext]')

// webpackModuleResult :: String -> String
const webpackModuleResult = (url) => (
[
'\t\t\t',
'var link = document.createElement(\'link\');',
'link.rel = \'import\';',
'link.href = ' + JSON.stringify(finalUrl) + ';',
'link.href = __webpack_public_path__ + ' + JSON.stringify(finalUrl) + ';',
'document.head.appendChild(link)',
// 'module.exports = __webpack_public_path__ + ' + JSON.stringify(url),
].join('\n\t\t\t')
Expand Down

0 comments on commit 3bb5598

Please sign in to comment.