· 7 years ago · Dec 10, 2018, 03:28 PM
1<html><head>
2 <meta charset="UTF-8">
3 <meta name="viewport" content="width=device-width">
4 <title>Ponynote</title>
5 </head>
6 <body>
7 <div id="root">
8 </div>
9 <script type="text/javascript" src="http://localhost:3000/static/js/bundle.js"></script>
10 </body></html>
11
12<html><head>
13 <meta charset="UTF-8">
14 <meta name="viewport" content="width=device-width">
15 <title>Ponynote</title>
16 </head>
17 <body>
18 <div id="root">
19 </div>
20 <script type="text/javascript" src="/static/bundles/js/main.a416835a.js"></script>
21<link type="text/css" href="/static/bundles/css/main.c17080f1.css" rel="stylesheet">
22 </body></html>
23
24{% load render_bundle from webpack_loader %}
25<!DOCTYPE html>
26<html>
27 <head>
28 <meta charset="UTF-8" />
29 <meta name="viewport" content="width=device-width" />
30 <title>Ponynote</title>
31 </head>
32 <body>
33 <div id="root">
34 </div>
35 {% render_bundle 'main' %}
36 </body>
37</html>
38
39import os
40
41# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
42BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
43
44
45# Quick-start development settings - unsuitable for production
46# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
47
48# SECURITY WARNING: keep the secret key used in production secret!
49SECRET_KEY = '=e%s=1kdk1_+yur9cmpkw8r-z5gd(owqpxbyl+6^)*10-a3c4v'
50
51# SECURITY WARNING: don't run with debug turned on in production!
52DEBUG = True
53
54ALLOWED_HOSTS = ['xx.xx.xx.xx']
55
56
57# Application definition
58
59INSTALLED_APPS = [
60 'django.contrib.admin',
61 'django.contrib.auth',
62 'django.contrib.contenttypes',
63 'django.contrib.sessions',
64 'django.contrib.messages',
65 'django.contrib.staticfiles',
66 'webpack_loader',
67]
68
69MIDDLEWARE = [
70 'django.middleware.security.SecurityMiddleware',
71 'django.contrib.sessions.middleware.SessionMiddleware',
72 'django.middleware.common.CommonMiddleware',
73 'django.middleware.csrf.CsrfViewMiddleware',
74 'django.contrib.auth.middleware.AuthenticationMiddleware',
75 'django.contrib.messages.middleware.MessageMiddleware',
76 'django.middleware.clickjacking.XFrameOptionsMiddleware',
77]
78
79ROOT_URLCONF = 'ponynote.urls'
80
81TEMPLATES = [
82 {
83 'BACKEND': 'django.template.backends.django.DjangoTemplates',
84 'DIRS': [os.path.join(BASE_DIR, "templates"), ],
85 'APP_DIRS': True,
86 'OPTIONS': {
87 'context_processors': [
88 'django.template.context_processors.debug',
89 'django.template.context_processors.request',
90 'django.contrib.auth.context_processors.auth',
91 'django.contrib.messages.context_processors.messages',
92 ],
93 },
94 },
95]
96
97WSGI_APPLICATION = 'ponynote.wsgi.application'
98
99
100# Database
101# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
102
103DATABASES = {
104 'default': {
105 'ENGINE': 'django.db.backends.sqlite3',
106 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
107 }
108}
109
110
111# Password validation
112# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
113
114AUTH_PASSWORD_VALIDATORS = [
115 {
116 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
117 },
118 {
119 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
120 },
121 {
122 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
123 },
124 {
125 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
126 },
127]
128
129
130# Internationalization
131# https://docs.djangoproject.com/en/1.11/topics/i18n/
132
133LANGUAGE_CODE = 'en-us'
134
135TIME_ZONE = 'UTC'
136
137USE_I18N = True
138
139USE_L10N = True
140
141USE_TZ = True
142
143
144# Static files (CSS, JavaScript, Images)
145# https://docs.djangoproject.com/en/1.11/howto/static-files/
146
147STATIC_URL = '/static/'
148
149
150WEBPACK_LOADER = {
151 'DEFAULT': {
152 'BUNDLE_DIR_NAME': 'bundles/',
153 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.dev.json'),
154 }
155}
156
157{
158 "name": "frontend",
159 "version": "0.1.0",
160 "private": true,
161 "dependencies": {
162 "autoprefixer": "7.1.2",
163 "babel-core": "6.25.0",
164 "babel-eslint": "7.2.3",
165 "babel-jest": "20.0.3",
166 "babel-loader": "7.1.1",
167 "babel-preset-react-app": "^3.0.3",
168 "babel-runtime": "6.26.0",
169 "case-sensitive-paths-webpack-plugin": "2.1.1",
170 "chalk": "1.1.3",
171 "css-loader": "0.28.4",
172 "dotenv": "4.0.0",
173 "eslint": "4.4.1",
174 "eslint-config-react-app": "^2.0.1",
175 "eslint-loader": "1.9.0",
176 "eslint-plugin-flowtype": "2.35.0",
177 "eslint-plugin-import": "2.7.0",
178 "eslint-plugin-jsx-a11y": "5.1.1",
179 "eslint-plugin-react": "7.1.0",
180 "extract-text-webpack-plugin": "3.0.0",
181 "file-loader": "0.11.2",
182 "fs-extra": "3.0.1",
183 "html-webpack-plugin": "2.29.0",
184 "jest": "20.0.4",
185 "object-assign": "4.1.1",
186 "postcss-flexbugs-fixes": "3.2.0",
187 "postcss-loader": "2.0.6",
188 "promise": "8.0.1",
189 "react": "^16.0.0",
190 "react-dev-utils": "^4.1.0",
191 "react-dom": "^16.0.0",
192 "style-loader": "0.18.2",
193 "sw-precache-webpack-plugin": "0.11.4",
194 "url-loader": "0.5.9",
195 "webpack": "3.5.1",
196 "webpack-dev-server": "2.8.2",
197 "webpack-manifest-plugin": "1.2.1",
198 "whatwg-fetch": "2.0.3"
199 },
200 "scripts": {
201 "start": "node scripts/start.js",
202 "build": "node scripts/build.js",
203 "test": "node scripts/test.js --env=jsdom"
204 },
205 "jest": {
206 "collectCoverageFrom": [
207 "src/**/*.{js,jsx}"
208 ],
209 "setupFiles": [
210 "<rootDir>/config/polyfills.js"
211 ],
212 "testMatch": [
213 "<rootDir>/src/**/__tests__/**/*.js?(x)",
214 "<rootDir>/src/**/?(*.)(spec|test).js?(x)"
215 ],
216 "testEnvironment": "node",
217 "testURL": "http://localhost",
218 "transform": {
219 "^.+\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
220 "^.+\.css$": "<rootDir>/config/jest/cssTransform.js",
221 "^(?!.*\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
222 },
223 "transformIgnorePatterns": [
224 "[/\\]node_modules[/\\].+\.(js|jsx)$"
225 ],
226 "moduleNameMapper": {
227 "^react-native$": "react-native-web"
228 },
229 "moduleFileExtensions": [
230 "web.js",
231 "js",
232 "json",
233 "web.jsx",
234 "jsx",
235 "node"
236 ]
237 },
238 "babel": {
239 "presets": [
240 "react-app"
241 ]
242 },
243 "eslintConfig": {
244 "extends": "react-app"
245 },
246 "proxy": "http://localhost:8000",
247 "devDependencies": {
248 "webpack-bundle-tracker": "^0.2.0"
249 }
250}
251
252'use strict';
253
254const autoprefixer = require('autoprefixer');
255const path = require('path');
256const webpack = require('webpack');
257const HtmlWebpackPlugin = require('html-webpack-plugin');
258const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
259const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
260const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
261const eslintFormatter = require('react-dev-utils/eslintFormatter');
262const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
263const getClientEnvironment = require('./env');
264const paths = require('./paths');
265const BundleTracker = require('webpack-bundle-tracker');
266
267
268// Webpack uses `publicPath` to determine where the app is being served from.
269// In development, we always serve from the root. This makes config easier.
270const publicPath = 'http://localhost:3000/';
271// `publicUrl` is just like `publicPath`, but we will provide it to our app
272// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
273// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
274const publicUrl = 'http://localhost:3000/';
275// Get environment variables to inject into our app.
276const env = getClientEnvironment(publicUrl);
277
278// This is the development configuration.
279// It is focused on developer experience and fast rebuilds.
280// The production configuration is different and lives in a separate file.
281module.exports = {
282 // You may want 'eval' instead if you prefer to see the compiled output in DevTools.
283 // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.
284 devtool: 'cheap-module-source-map',
285 // These are the "entry points" to our application.
286 // This means they will be the "root" imports that are included in JS bundle.
287 // The first two entry points enable "hot" CSS and auto-refreshes for JS.
288 entry: [
289 // We ship a few polyfills by default:
290 require.resolve('./polyfills'),
291 // Include an alternative client for WebpackDevServer. A client's job is to
292 // connect to WebpackDevServer by a socket and get notified about changes.
293 // When you save a file, the client will either apply hot updates (in case
294 // of CSS changes), or refresh the page (in case of JS changes). When you
295 // make a syntax error, this client will display a syntax error overlay.
296 // Note: instead of the default WebpackDevServer client, we use a custom one
297 // to bring better experience for Create React App users. You can replace
298 // the line below with these two lines if you prefer the stock client:
299 require.resolve('webpack-dev-server/client') + '?http://localhost:3000',
300 require.resolve('webpack/hot/dev-server'),
301 // require.resolve('react-dev-utils/webpackHotDevClient'),
302 // Finally, this is your app's code:
303 paths.appIndexJs,
304 // We include the app code last so that if there is a runtime error during
305 // initialization, it doesn't blow up the WebpackDevServer client, and
306 // changing JS code would still trigger a refresh.
307 ],
308 output: {
309 // Next line is not used in dev but WebpackDevServer crashes without it:
310 path: paths.appBuild,
311 // Add /* filename */ comments to generated require()s in the output.
312 pathinfo: true,
313 // This does not produce a real file. It's just the virtual path that is
314 // served by WebpackDevServer in development. This is the JS bundle
315 // containing code from all our entry points, and the Webpack runtime.
316 filename: 'static/js/bundle.js',
317 // There are also additional JS chunk files if you use code splitting.
318 chunkFilename: 'static/js/[name].chunk.js',
319 // This is the URL that app is served from. We use "/" in development.
320 publicPath: publicPath,
321 // Point sourcemap entries to original disk location (format as URL on Windows)
322 devtoolModuleFilenameTemplate: info =>
323 path.resolve(info.absoluteResourcePath).replace(/\/g, '/'),
324 },
325 resolve: {
326 // This allows you to set a fallback for where Webpack should look for modules.
327 // We placed these paths second because we want `node_modules` to "win"
328 // if there are any conflicts. This matches Node resolution mechanism.
329 // https://github.com/facebookincubator/create-react-app/issues/253
330 modules: ['node_modules', paths.appNodeModules].concat(
331 // It is guaranteed to exist because we tweak it in `env.js`
332 process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
333 ),
334 // These are the reasonable defaults supported by the Node ecosystem.
335 // We also include JSX as a common component filename extension to support
336 // some tools, although we do not recommend using it, see:
337 // https://github.com/facebookincubator/create-react-app/issues/290
338 // `web` extension prefixes have been added for better support
339 // for React Native Web.
340 extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'],
341 alias: {
342
343 // Support React Native Web
344 // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
345 'react-native': 'react-native-web',
346 },
347 plugins: [
348 // Prevents users from importing files from outside of src/ (or node_modules/).
349 // This often causes confusion because we only process files within src/ with babel.
350 // To fix this, we prevent you from importing files out of src/ -- if you'd like to,
351 // please link the files into your node_modules/ and let module-resolution kick in.
352 // Make sure your source files are compiled, as they will not be processed in any way.
353 new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
354 ],
355 },
356 module: {
357 strictExportPresence: true,
358 rules: [
359 // TODO: Disable require.ensure as it's not a standard language feature.
360 // We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176.
361 // { parser: { requireEnsure: false } },
362
363 // First, run the linter.
364 // It's important to do this before Babel processes the JS.
365 {
366 test: /.(js|jsx)$/,
367 enforce: 'pre',
368 use: [
369 {
370 options: {
371 formatter: eslintFormatter,
372 eslintPath: require.resolve('eslint'),
373
374 },
375 loader: require.resolve('eslint-loader'),
376 },
377 ],
378 include: paths.appSrc,
379 },
380 {
381 // "oneOf" will traverse all following loaders until one will
382 // match the requirements. When no loader matches it will fall
383 // back to the "file" loader at the end of the loader list.
384 oneOf: [
385 // "url" loader works like "file" loader except that it embeds assets
386 // smaller than specified limit in bytes as data URLs to avoid requests.
387 // A missing `test` is equivalent to a match.
388 {
389 test: [/.bmp$/, /.gif$/, /.jpe?g$/, /.png$/],
390 loader: require.resolve('url-loader'),
391 options: {
392 limit: 10000,
393 name: 'static/media/[name].[hash:8].[ext]',
394 },
395 },
396 // Process JS with Babel.
397 {
398 test: /.(js|jsx)$/,
399 include: paths.appSrc,
400 loader: require.resolve('babel-loader'),
401 options: {
402
403 // This is a feature of `babel-loader` for webpack (not Babel itself).
404 // It enables caching results in ./node_modules/.cache/babel-loader/
405 // directory for faster rebuilds.
406 cacheDirectory: true,
407 },
408 },
409 // "postcss" loader applies autoprefixer to our CSS.
410 // "css" loader resolves paths in CSS and adds assets as dependencies.
411 // "style" loader turns CSS into JS modules that inject <style> tags.
412 // In production, we use a plugin to extract that CSS to a file, but
413 // in development "style" loader enables hot editing of CSS.
414 {
415 test: /.css$/,
416 use: [
417 require.resolve('style-loader'),
418 {
419 loader: require.resolve('css-loader'),
420 options: {
421 importLoaders: 1,
422 },
423 },
424 {
425 loader: require.resolve('postcss-loader'),
426 options: {
427 // Necessary for external CSS imports to work
428 // https://github.com/facebookincubator/create-react-app/issues/2677
429 ident: 'postcss',
430 plugins: () => [
431 require('postcss-flexbugs-fixes'),
432 autoprefixer({
433 browsers: [
434 '>1%',
435 'last 4 versions',
436 'Firefox ESR',
437 'not ie < 9', // React doesn't support IE8 anyway
438 ],
439 flexbox: 'no-2009',
440 }),
441 ],
442 },
443 },
444 ],
445 },
446 // "file" loader makes sure those assets get served by WebpackDevServer.
447 // When you `import` an asset, you get its (virtual) filename.
448 // In production, they would get copied to the `build` folder.
449 // This loader doesn't use a "test" so it will catch all modules
450 // that fall through the other loaders.
451 {
452 // Exclude `js` files to keep "css" loader working as it injects
453 // it's runtime that would otherwise processed through "file" loader.
454 // Also exclude `html` and `json` extensions so they get processed
455 // by webpacks internal loaders.
456 exclude: [/.js$/, /.html$/, /.json$/],
457 loader: require.resolve('file-loader'),
458 options: {
459 name: 'static/media/[name].[hash:8].[ext]',
460 },
461 },
462 ],
463 },
464 // ** STOP ** Are you adding a new loader?
465 // Make sure to add the new loader(s) before the "file" loader.
466 ],
467 },
468 plugins: [
469 // Makes some environment variables available in index.html.
470 // The public URL is available as %PUBLIC_URL% in index.html, e.g.:
471 // <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
472 // In development, this will be an empty string.
473 new InterpolateHtmlPlugin(env.raw),
474 // Generates an `index.html` file with the <script> injected.
475 new HtmlWebpackPlugin({
476 inject: true,
477 template: paths.appHtml,
478 }),
479 // Add module names to factory functions so they appear in browser profiler.
480 new webpack.NamedModulesPlugin(),
481 // Makes some environment variables available to the JS code, for example:
482 // if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
483 new webpack.DefinePlugin(env.stringified),
484 // This is necessary to emit hot updates (currently CSS only):
485 new webpack.HotModuleReplacementPlugin(),
486 // Watcher doesn't work well if you mistype casing in a path so we use
487 // a plugin that prints an error when you attempt to do this.
488 // See https://github.com/facebookincubator/create-react-app/issues/240
489 new CaseSensitivePathsPlugin(),
490 // If you require a missing module and then `npm install` it, you still have
491 // to restart the development server for Webpack to discover it. This plugin
492 // makes the discovery automatic so you don't have to restart.
493 // See https://github.com/facebookincubator/create-react-app/issues/186
494 new WatchMissingNodeModulesPlugin(paths.appNodeModules),
495 // Moment.js is an extremely popular library that bundles large locale files
496 // by default due to how Webpack interprets its code. This is a practical
497 // solution that requires the user to opt into importing specific locales.
498 // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
499 // You can remove this if you don't use Moment.js:
500 new webpack.IgnorePlugin(/^./locale$/, /moment$/),
501 new BundleTracker({path: paths.statsRoot, filename: 'webpack-stats.dev.json'}),
502 ],
503 // Some libraries import Node modules but don't use them in the browser.
504 // Tell Webpack to provide empty mocks for them so importing them works.
505 node: {
506 dgram: 'empty',
507 fs: 'empty',
508 net: 'empty',
509 tls: 'empty',
510 child_process: 'empty',
511 },
512 // Turn off performance hints during development because we don't do any
513 // splitting or minification in interest of speed. These warnings become
514 // cumbersome.
515 performance: {
516 hints: false,
517 },
518};
519
520server {
521 listen 80;
522 server_name xx.xx.xx.xx;
523
524 passenger_python /var/www/ponynote/venv36/bin/python3.6;
525
526 # Tell Nginx and Passenger where your app's 'public' directory is
527 root /var/www/ponynote/ponynote/ponynote;
528
529 # Turn on Passenger
530 passenger_enabled on;
531}
532
533import ponynote.wsgi
534application = ponynote.wsgi.application
535
536import os
537from django.core.wsgi import get_wsgi_application
538os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ponynote.production_settings")
539application = get_wsgi_application()
540
541from .settings import *
542STATICFILES_DIRS = [
543 os.path.join(BASE_DIR, "assets"),
544]
545
546WEBPACK_LOADER = {
547 'DEFAULT': {
548 'BUNDLE_DIR_NAME': 'bundles/',
549 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.prod.json'),
550 }
551}