Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Style in package.json #6

Open
stephanedemotte opened this issue Jul 22, 2020 · 3 comments
Open

Get Style in package.json #6

stephanedemotte opened this issue Jul 22, 2020 · 3 comments

Comments

@stephanedemotte
Copy link

stephanedemotte commented Jul 22, 2020

Hello,
How can i have the style.css ?

I got only a js file.

{
  "index.js": "index.46558eb7.js"
}

Thanks for the plugin !!

@stephanedemotte stephanedemotte changed the title Get Style in the package.json Get Style in package.json Aug 5, 2020
@dmail
Copy link

dmail commented Aug 7, 2020

I wanted to use this project and found out that asset does not appear in the manifest.json.
According to your source code asset did not have name and are filtered out:

// only output chunk, because asset has no attribute name

Since rollup had changes and asset got both a fileName and name property according to their documentation (I have tested locally and I confirm): https://rollupjs.org/guide/en/#generatebundle.

rollup js 2020-08-07 14-36-34

It means your rollup version is outdated.
And also you should pass a custom filter because only entry are remapped by default

outputManifest({
  filter: () => true
})

@flayks
Copy link

flayks commented Aug 12, 2020

I'm also looking into adding CSS files in the manifest 👀

@shuizhongyueming
Copy link
Owner

I have updated this plugin with the support to collect assets to manifest.

As @dmail mentioned, AssetInfo.name is optional. if the plugin processes such asset but don't provide the name attribute, our manifest plugin will omit it.

You can add the name attribute with a custom map

Here is an example to output css assets which is pre processed by the rollup-plugin-postcss to the manifest

import outputManifest, {isAsset} from 'rollup-plugin-output-manifest'
import postcss from 'rollup-plugin-postcss'

export default {
  input: {
    pageA: './page-a.js',
    pageB: './page-b.js',
    pageC: './page-c.js',
  },
  plugins: [
    postcss({extract: true}),
    outputManifest({
      fileName: "manifest.json",
      map: bundle => {
        if (isAsset(bundle) && !bundle.name) {
          // gen name from fileName
          // base on output.assetFileNames
          const baseName = bundle.fileName.split('-')[0];
          bundle.name = baseName;
        }
        return bundle;
      }
    })
  ],
  output: {
    entryFileNames: '[name]-[hash].js',
    assetFileNames: '[name]-[hash].[extname]',
    dir: './dist/',
    format: 'esm',
  },
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants