Skip to content

Commit

Permalink
Include assets from "assets/" directory (#130)
Browse files Browse the repository at this point in the history
Copy (without hashing) all files in the `assets` directory to the `output/{mode}/assets` directory.
  • Loading branch information
mwistrand authored Aug 13, 2018
1 parent 4f285ab commit 5ef169b
Show file tree
Hide file tree
Showing 8 changed files with 3,804 additions and 3,647 deletions.
5,958 changes: 3,000 additions & 2,958 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@dojo/cli": "~3.0.0",
"@dojo/scripts": "~3.0.1",
"@types/clean-webpack-plugin": "0.1.0",
"@types/copy-webpack-plugin": "4.4.1",
"@types/execa": "0.8.0",
"@types/express": "4.11.0",
"@types/extract-text-webpack-plugin": "3.0.0",
Expand Down Expand Up @@ -103,6 +104,7 @@
"auto-require-webpack-plugin": "1.0.1",
"chalk": "2.4.1",
"clean-webpack-plugin": "0.1.17",
"copy-webpack-plugin": "4.5.2",
"cli-columns": "3.1.2",
"css-loader": "0.28.7",
"express": "4.16.2",
Expand Down
8 changes: 7 additions & 1 deletion src/dev.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import baseConfigFactory, { mainEntry, packageName } from './base.config';
import { WebAppManifest } from './interfaces';
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
import * as fs from 'fs';
import * as path from 'path';
import webpack = require('webpack');
import { deepAssign } from '@dojo/framework/core/lang';
Expand All @@ -9,6 +10,7 @@ import ServiceWorkerPlugin, {
ServiceWorkerOptions
} from '@dojo/webpack-contrib/service-worker-plugin/ServiceWorkerPlugin';
import * as CleanWebpackPlugin from 'clean-webpack-plugin';
import * as CopyWebpackPlugin from 'copy-webpack-plugin';
import * as ManifestPlugin from 'webpack-manifest-plugin';

const WebpackPwaManifest = require('webpack-pwa-manifest');
Expand All @@ -18,9 +20,13 @@ function webpackConfig(args: any): webpack.Configuration {
const manifest: WebAppManifest = args.pwa && args.pwa.manifest;
const serviceWorker: string | ServiceWorkerOptions = args.pwa && args.pwa.serviceWorker;
const { plugins, output, module } = config;
const outputPath = path.join(output.path!, 'dev');
const assetsDir = path.join(process.cwd(), 'assets');
const assetsDirExists = fs.existsSync(assetsDir);

config.plugins = [
...plugins,
assetsDirExists && new CopyWebpackPlugin([{ from: assetsDir, to: path.join(outputPath, 'assets') }]),
new ManifestPlugin(),
new HtmlWebpackPlugin({
inject: true,
Expand Down Expand Up @@ -80,7 +86,7 @@ function webpackConfig(args: any): webpack.Configuration {

config.output = {
...output,
path: path.join(output.path!, 'dev')
path: outputPath
};

config.devtool = 'inline-source-map';
Expand Down
8 changes: 7 additions & 1 deletion src/dist.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import baseConfigFactory, { mainEntry, packageName } from './base.config';
import { WebAppManifest } from './interfaces';
import webpack = require('webpack');
import * as fs from 'fs';
import * as path from 'path';
import { deepAssign } from '@dojo/framework/core/lang';
import BuildTimeRender from '@dojo/webpack-contrib/build-time-render/BuildTimeRender';
Expand All @@ -10,6 +11,7 @@ import ServiceWorkerPlugin, {
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
import * as ExtractTextPlugin from 'extract-text-webpack-plugin';
import * as CleanWebpackPlugin from 'clean-webpack-plugin';
import * as CopyWebpackPlugin from 'copy-webpack-plugin';
import * as ManifestPlugin from 'webpack-manifest-plugin';
import * as WebpackChunkHash from 'webpack-chunk-hash';

Expand All @@ -22,9 +24,13 @@ function webpackConfig(args: any): webpack.Configuration {
const manifest: WebAppManifest = args.pwa && args.pwa.manifest;
const serviceWorker: ServiceWorkerOptions = args.pwa && args.pwa.serviceWorker;
const { plugins, output } = config;
const outputPath = path.join(output.path!, 'dist');
const assetsDir = path.join(process.cwd(), 'assets');
const assetsDirExists = fs.existsSync(assetsDir);

config.plugins = [
...plugins,
assetsDirExists && new CopyWebpackPlugin([{ from: assetsDir, to: path.join(outputPath, 'assets') }]),
new ManifestPlugin(),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
Expand Down Expand Up @@ -94,7 +100,7 @@ function webpackConfig(args: any): webpack.Configuration {

config.output = {
...output,
path: path.join(output.path!, 'dist'),
path: outputPath,
chunkFilename: '[name].[chunkhash].bundle.js',
filename: '[name].[chunkhash].bundle.js'
};
Expand Down
90 changes: 90 additions & 0 deletions test-app/assets/dojo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5ef169b

Please sign in to comment.