zorigitano / multipage-webpack-plugin

A plugin that makes handling templates and asset distribution for multi-page applications using webpack trivial
Apache License 2.0
170 stars 15 forks source link

Design - MVP - Defaults - Templates #5

Closed TheLarkInn closed 7 years ago

TheLarkInn commented 7 years ago

Scenario (Defaults) ( #4 )

Fixture

webpack.config.js

const MultipageWebpackPlugin = require(multipage-webpack-plugin);

const config = {
  entry: {
    a: './src/a.js',
    b: './src/b.js'
  },
  output: {
    filename: '[name].chunk.js',
    path: path.join(__dirname, "dist")
  },
  module: {
    /* ... */
  },
  plugins: [
    new MultipageWebpackPlugin()
  ]
};

module.exports = config;

Templates

What should we define as the default template output type? We use the most simple and compatible template across MVC frameworks and that is .html.

Since under the hood this POC leverages html-webpack-plugin the output/emitted template file makes sense to be .html. By default there would be automatic handling of where script tags should be placed etc.

What should the default output path and organization (directory structure) for each template? Each template should be emitted into their own subdirectory inside of the specified path found in config.output.path. This sub directory by default would be sane to match the entry name. This way each template can be accessed and served with simple http-server or liteserver or whatever else is out there.

Example derived from fixture above:

├── dist/
│   ├── a/ 
│   ├─── index.html
│   ├── b/ 
│   ├─── index.html