diff --git a/src/Pipeline.js b/src/Pipeline.js
index 16c9a9c5b02..4d20622ae3c 100644
--- a/src/Pipeline.js
+++ b/src/Pipeline.js
@@ -65,6 +65,12 @@ class Pipeline {
subAsset.cacheData = Object.assign(asset.cacheData, subAsset.cacheData);
let processed = await this.processAsset(subAsset);
+ if (rendition.meta) {
+ for (let res of processed) {
+ res.meta = rendition.meta;
+ }
+ }
+
generated = generated.concat(processed);
asset.hash = md5(asset.hash + subAsset.hash);
} else {
diff --git a/src/assets/CSSAsset.js b/src/assets/CSSAsset.js
index 4cf066ac1f0..db4631ef53a 100644
--- a/src/assets/CSSAsset.js
+++ b/src/assets/CSSAsset.js
@@ -29,19 +29,19 @@ class CSSAsset extends Asset {
collectDependencies() {
this.ast.root.walkAtRules('import', rule => {
- let params = valueParser(rule.params).nodes;
- let [name, ...media] = params;
+ let params = valueParser(rule.params);
+ let [name, ...media] = params.nodes;
let dep;
- if (name.type === 'string') {
- dep = name.value;
- } else if (
+ if (
name.type === 'function' &&
name.value === 'url' &&
name.nodes.length
) {
- dep = name.nodes[0].value;
+ name = name.nodes[0];
}
+ dep = name.value;
+
if (!dep) {
throw new Error('Could not find import name for ' + rule);
}
@@ -50,10 +50,19 @@ class CSSAsset extends Asset {
return;
}
- media = valueParser.stringify(media).trim();
- this.addDependency(dep, {media, loc: rule.source.start});
+ // If this came from an inline '
- )
+ html.includes('')
);
- // minifyJson
+ // mergeStyles
assert(
- html.includes('')
+ html.includes(
+ ''
+ )
);
// minifySvg is false
@@ -589,4 +589,108 @@ describe('html', function() {
]
});
});
+
+ it('should process inline JS', async function() {
+ let b = await bundle(__dirname + '/integration/html-inline-js/index.html', {
+ production: true
+ });
+
+ const bundleContent = (await fs.readFile(b.name)).toString();
+ assert(!bundleContent.includes('someArgument'));
+ });
+
+ it('should process inline styles', async function() {
+ let b = await bundle(
+ __dirname + '/integration/html-inline-styles/index.html',
+ {production: true}
+ );
+
+ await assertBundleTree(b, {
+ name: 'index.html',
+ assets: ['index.html'],
+ childBundles: [
+ {
+ type: 'jpg',
+ assets: ['bg.jpg'],
+ childBundles: []
+ },
+ {
+ type: 'jpg',
+ assets: ['img.jpg'],
+ childBundles: []
+ }
+ ]
+ });
+ });
+
+ it('should process inline styles using lang', async function() {
+ let b = await bundle(
+ __dirname + '/integration/html-inline-sass/index.html',
+ {production: true}
+ );
+
+ await assertBundleTree(b, {
+ name: 'index.html',
+ assets: ['index.html']
+ });
+
+ let html = await fs.readFile(__dirname + '/dist/index.html', 'utf8');
+
+ assert(html.includes(''));
+ });
+
+ it('should process inline non-js scripts', async function() {
+ let b = await bundle(
+ __dirname + '/integration/html-inline-coffeescript/index.html',
+ {production: true}
+ );
+
+ await assertBundleTree(b, {
+ name: 'index.html',
+ assets: ['index.html']
+ });
+
+ let html = await fs.readFile(__dirname + '/dist/index.html', 'utf8');
+
+ assert(html.includes('alert("Hello, World!")'));
+ });
+
+ it('should handle inline css with @imports', async function() {
+ let b = await bundle(
+ __dirname + '/integration/html-inline-css-import/index.html',
+ {production: true}
+ );
+
+ await assertBundleTree(b, {
+ name: 'index.html',
+ assets: ['index.html'],
+ childBundles: [
+ {
+ type: 'css',
+ assets: ['test.css']
+ }
+ ]
+ });
+
+ let html = await fs.readFile(__dirname + '/dist/index.html', 'utf8');
+ assert(html.includes('@import'));
+ });
+
+ it('should error on imports and requires in inline
+