UNPKG

@viewdo/dxp-story-cli

Version:
84 lines (79 loc) 2.66 kB
// NPM Module Dependencies const deepmerge = require('deepmerge'); const path = require('path'); // Rules/Settings const css = require('./css'); const es2015 = require('./es2018'); /** * Creates the basic webpack config file for all stories. In this case it will extract * any instance of the css from any of the JS files and also transpile ES6. * * @param {Object} storyInfo - Information about the build process for this * story * @param {String} buildPath - Destination to build the files after webpack * @param {Object} cssExtractor - Instance of the Text Extractor to pull the CSS file into. */ module.exports = (sourcePath, buildPath, episodeKey, cssExtractor, dev = false) => { const cssSettings = css(cssExtractor, dev); const jsSettings = es2015(); return Object.assign(deepmerge(cssSettings, jsSettings), { devtool: dev ? "inline-source-map" : dev, entry: `${sourcePath}/${episodeKey}.js`, mode: 'production', output: { filename: `story.js`, path: path.resolve(buildPath) }, module: { rules: [ { test: /\.md$/, use: [ { loader: "html-loader" }, { loader: "markdown-loader", options: { } } ] }, { test: /\.html$/, use: [ 'raw-loader' ] }, { test: /\.(jpe?g|gif|png|svg)$/, loader: "file-loader", options: { name: '[name].[ext]', publicPath: '', outputPath: 'images/' } }, { test: /\.(woff|ttf|eot)$/, loader: "file-loader", options: { name: '[name].[ext]', publicPath: '', outputPath: 'fonts/' } }, { test: /\.(wav|mp3)$/, loader: "file-loader", options: { name: '[name].[ext]', publicPath: '', outputPath: 'misc/' } } ] }, plugins: [] }); }