12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- const path = require('path');
- const webpack = require('webpack');
- const ProvidePlugin = webpack.ProvidePlugin;
- const CopyPlugin = require('copy-webpack-plugin');
- const srcPath = path.join(__dirname, 'src');
- function externalCss (context, request, callback) {
- if (!/\.css$/.test(request)) {
- return callback();
- }
- const sourceFilename = path.resolve(context, request);
- const relativeSource = path.relative(srcPath, sourceFilename);
- const fileRequest = ['.', relativeSource].join(path.sep);
- return callback(null, `umd ${fileRequest}`);
- }
- module.exports = function (_, options) {
- return {
- stats: 'minimal',
- entry: {
- index: path.join(__dirname, 'src', 'index.js')
- },
- output: {
- path: path.join(__dirname, 'dist'),
- filename: '[name].js',
- libraryTarget: 'umd'
- },
- devtool: 'source-map',
- externals: [
- 'hyperapp',
- externalCss
- ],
- module: {
- rules: [
- {
- test: /\.jsx?$/,
- use: [
- {
- loader: 'babel-loader',
- options: {
- presets: [
- ['@babel/preset-env', {
- modules: false
- }]
- ],
- plugins: [
- ['@babel/plugin-transform-react-jsx', {
- pragma: 'h'
- }]
- ]
- }
- }
- ]
- }
- ]
- },
- plugins: [
- new ProvidePlugin({
- h: ['hyperapp', 'h']
- }),
- new CopyPlugin([
- {
- from: '**/*.css',
- to: './',
- context: 'src'
- }
- ])
- ]
- };
- };
|