Giter VIP home page Giter VIP logo

rollup-plugin-fill-html's Issues

Something wrong when rollup.config.js export an array

// rollup.config.js
import commonjs    from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
import babel       from 'rollup-plugin-babel';
import Replace     from 'rollup-plugin-replace';
import serve       from 'rollup-plugin-serve'
import livereload  from 'rollup-plugin-livereload'
import uglify      from 'rollup-plugin-uglify';
import html        from 'rollup-plugin-fill-html';

const isProduction = process.env.NODE_ENV === 'production'

function setConfig (options) {
  const config = {
    input: options.input,
    output: {
      file: isProduction ? options.output.minifyFilename : options.output.filename,
      format: 'iife',
      sourcemap: isProduction ? false : 'inline'
    },
    plugins: [
      babel({
        exclude: 'node_modules/**' // only transpile our source code
      }),
      nodeResolve(),
      commonjs({
        namedExports: {
          'node_modules/react/index.js': ['Children', 'Component', 'createElement']
        }
      }),
      Replace({
        'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
      }),
      html({
        template: options.html.template,
        filename: options.html.filename
      })
      // browsersync({server: 'home'})
    ]
  }

  if (isProduction) {
    config.plugins = config.plugins.concat([
      // hash({
      // 	dest: options.output.minifyFilename
      // }),
      uglify({
        compress: {
          warnings: false,
          drop_console: true
        },
        output: {
          comments: false
        }
      })
    ])
  } else {
    // config.plugins = config.plugins.concat([
    //   serve({
    //     open: true,
    //     historyApiFallback: true,
    //     contentBase: ['./dist'],
    //     port: 8080,
    //   }),
    //   livereload()
    // ])
  }

  return config
}

const configs = [
  setConfig({
    input: './src/auth/main.js',
    output: {
      minifyFilename: './dist/auth/index.min.[hash].js',
      filename: './dist/auth/index.js'
    },
    html: {
      template: './src/auth/index.html',
      filename: 'auth/index.html',
    }
  }),
  setConfig({
    input: './src/home/main.js',
    output: {
      minifyFilename: './dist/home/index.min.[hash].js',
      filename: './dist/home/index.js'
    },
    html: {
      template: './src/home/index.html',
      filename: 'home/index.html',
    }
  })
]

export default configs

I got this in auth/index.html
image

and i got this in home/index.html
image

By the way, the path is not my expectation
image

Wrong html output filename, sourcemap not hashed

I just checkout to this repo, go to examples, npm i, npm run start and I found next files:

bundle-7c3eb3d0c53e714ec52ed127228f3dca.js
html>?

Expected index.html.
Actual: html>?

Also, in my project I got next files:

bundle-49e343424623b366c24fd9d0ed9cdcb5.js
bundle-[hash].js.map
html>

Expected: bundle-49e343424623b366c24fd9d0ed9cdcb5.map.js
Actual: bundle-[hash].js.map

experimentalCodeSplitting Path must be a string. Received undefined

I'm getting

[!] TypeError: Path must be a string. Received undefined

I think it's because i'm trying to use experimentalCodeSplitting and instead of a single output we i'm making an array

export default [{
	experimentalCodeSplitting: true,
	input: ['app/scripts/main.js', 'app/scripts/login.js'],
	output: {
		format: 'cjs',
		name: 'bundle-[hash]',
		sourcemap: true,
		dir: 'app/dist',
		entryNames: '[alias]-[hash].js'
	},
	plugins: [
	html({
		template: 'app/templates/index.html',
		filename: 'index.html'
	})
        ]
}]

Support type="module"

Most browsers now support <script type="module">
It would be great if this were an options for this utility.

Sure, ideally it would somehow know which to use for which, but to begin with I figure:
a) a setting for all generated bundles to use
b) a setting for externals [or per external?]

Breaks under latest rollup version due to change in configuration structure

Seems this is not compatible with the latest rollup version released a few days ago.

Running [email protected] alongside [email protected] I get the following error:

[!] Error: ENOENT: no such file or directory, scandir ''
Error: ENOENT: no such file or directory, scandir ''
    at Object.fs.readdirSync (fs.js:910:18)
    at traverse (/Users/lirsacc/projects/sample-project/node_modules/rollup-plugin-fill-html/dist/index.cjs.js:102:20)
    at Object.onwrite (/Users/lirsacc/projects/sample-project/node_modules/rollup-plugin-fill-html/dist/index.cjs.js:162:4)
    at /Users/lirsacc/projects/sample-project/node_modules/rollup/dist/rollup.js:10609:40
    at next (/Users/lirsacc/projects/sample-project/node_modules/rollup/dist/rollup.js:148:27)
    at /Users/lirsacc/projects/sample-project/node_modules/rollup/dist/rollup.js:152:48
    at <anonymous>

I've tracked it down to https://github.com/alwaysonlinetxm/rollup-plugin-fill-html/blob/master/src/index.js#L32 where config.dest is now undefined and the file path is now available under config.file. I guess this applies to the multi-targets case a couple lines down as well.

Some details on the config changes can be found in this gist according to rollup's changelog.

Sorry for the noise in case you're already working on that; if not I could also make a PR with a fix if I find some time over the weekend.

ENOENT: no such file or directory in Windows

I like simplicity of implementing hashing, unfortunately it doesn't work in Windows. It uses hardcoded segment separator ('/') instead of path.sep.

ENOENT: no such file or directory, scandir 'C:\xxx\dist\bundle.7052a28fe691982e9d8e3649e7e9ff7d.j'
Error: ENOENT: no such file or directory, scandir 'C:\xxx\dist\bundle.7052a28fe691982e9d8e3649e7e9ff7d.j'
at Error (native)
at Object.fs.readdirSync (fs.js:951:18)
at traverse (C:\xxx\node_modules\rollup-plugin-fill-html\dist\index.cjs.js:102:20)
at Object.onwrite (C:\xxx\node_modules\rollup-plugin-fill-html\dist\index.cjs.js:157:7)
at C:\xxx\node_modules\rollup\src\rollup.js:123:38
at next (C:\xxx\node_modules\rollup\src\utils\promise.js:6:10)
at C:\xxx\node_modules\rollup\src\utils\promise.js:10:33
Type rollup --help for help, or visit https://github.com/rollup/rollup/wiki
error Command failed with exit code 1.

Absolute path for SPAs

The plugin will add the bundle like src="app.js".

But I'm building a single page application, where refreshing the browser at any path will always server the same page. E.g. /a/b/c always serves the same index.html.

Because the path is relative app.js. The page cannot find the bundle. Could you add a config option to add this as absolute path? e.g. /app.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.