Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include assets from "assets/" directory #126

Merged
merged 6 commits into from
Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,005 changes: 3,025 additions & 2,980 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