diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-12 11:38:02 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-12 11:42:48 +0100 |
commit | 7bfd1b1edb7ea4ea6516b6a74c4e9af938d0bdc6 (patch) | |
tree | 722781d5d89fe438e7491da7e9d09dedd8c82a74 /client/config/webpack.dev.js | |
parent | 63c4db6d71b98523753c51747e308682d9a2e8a0 (diff) | |
download | PeerTube-7bfd1b1edb7ea4ea6516b6a74c4e9af938d0bdc6.tar.gz PeerTube-7bfd1b1edb7ea4ea6516b6a74c4e9af938d0bdc6.tar.zst PeerTube-7bfd1b1edb7ea4ea6516b6a74c4e9af938d0bdc6.zip |
Upgrade scripts and embed webpack config
Diffstat (limited to 'client/config/webpack.dev.js')
-rw-r--r-- | client/config/webpack.dev.js | 242 |
1 files changed, 0 insertions, 242 deletions
diff --git a/client/config/webpack.dev.js b/client/config/webpack.dev.js deleted file mode 100644 index d825f40e0..000000000 --- a/client/config/webpack.dev.js +++ /dev/null | |||
@@ -1,242 +0,0 @@ | |||
1 | const helpers = require('./helpers') | ||
2 | const webpackMerge = require('webpack-merge') // used to merge webpack configs | ||
3 | const webpackMergeDll = webpackMerge.strategy({plugins: 'replace'}) | ||
4 | const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev | ||
5 | const videoEmbedConfig = require('./webpack.video-embed.js') | ||
6 | |||
7 | /** | ||
8 | * Webpack Plugins | ||
9 | */ | ||
10 | const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin') | ||
11 | const DefinePlugin = require('webpack/lib/DefinePlugin') | ||
12 | const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin') | ||
13 | const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin') | ||
14 | const HotModuleReplacementPlugin = require('webpack/lib/HotModuleReplacementPlugin') | ||
15 | |||
16 | /** | ||
17 | * Webpack Constants | ||
18 | */ | ||
19 | const ENV = process.env.ENV = process.env.NODE_ENV = 'development' | ||
20 | const HOST = process.env.HOST || 'localhost' | ||
21 | const PORT = process.env.PORT || 3000 | ||
22 | const PUBLIC = process.env.PUBLIC_DEV || HOST + ':' + PORT | ||
23 | const AOT = process.env.BUILD_AOT || helpers.hasNpmFlag('aot') | ||
24 | const HMR = helpers.hasProcessFlag('hot') | ||
25 | const METADATA = { | ||
26 | host: HOST, | ||
27 | port: PORT, | ||
28 | public: PUBLIC, | ||
29 | ENV: ENV, | ||
30 | HMR: HMR, | ||
31 | AOT: AOT, | ||
32 | API_URL: 'http://localhost:9000' | ||
33 | } | ||
34 | |||
35 | const DllBundlesPlugin = require('webpack-dll-bundles-plugin').DllBundlesPlugin | ||
36 | |||
37 | /** | ||
38 | * Webpack configuration | ||
39 | * | ||
40 | * See: http://webpack.github.io/docs/configuration.html#cli | ||
41 | */ | ||
42 | module.exports = function (env) { | ||
43 | return [ | ||
44 | |||
45 | webpackMerge(commonConfig({ env: ENV }), { | ||
46 | /** | ||
47 | * Developer tool to enhance debugging | ||
48 | * | ||
49 | * See: http://webpack.github.io/docs/configuration.html#devtool | ||
50 | * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps | ||
51 | */ | ||
52 | devtool: 'cheap-module-source-map', | ||
53 | |||
54 | /** | ||
55 | * Options affecting the output of the compilation. | ||
56 | * | ||
57 | * See: http://webpack.github.io/docs/configuration.html#output | ||
58 | */ | ||
59 | output: { | ||
60 | /** | ||
61 | * The output directory as absolute path (required). | ||
62 | * | ||
63 | * See: http://webpack.github.io/docs/configuration.html#output-path | ||
64 | */ | ||
65 | path: helpers.root('dist'), | ||
66 | |||
67 | /** | ||
68 | * Specifies the name of each output file on disk. | ||
69 | * IMPORTANT: You must not specify an absolute path here! | ||
70 | * | ||
71 | * See: http://webpack.github.io/docs/configuration.html#output-filename | ||
72 | */ | ||
73 | filename: '[name].bundle.js', | ||
74 | |||
75 | /** | ||
76 | * The filename of the SourceMaps for the JavaScript files. | ||
77 | * They are inside the output.path directory. | ||
78 | * | ||
79 | * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename | ||
80 | */ | ||
81 | sourceMapFilename: '[name].map', | ||
82 | |||
83 | /** The filename of non-entry chunks as relative path | ||
84 | * inside the output.path directory. | ||
85 | * | ||
86 | * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename | ||
87 | */ | ||
88 | chunkFilename: '[id].chunk.js', | ||
89 | |||
90 | library: 'ac_[name]', | ||
91 | libraryTarget: 'var' | ||
92 | }, | ||
93 | |||
94 | plugins: [ | ||
95 | |||
96 | /** | ||
97 | * Plugin: DefinePlugin | ||
98 | * Description: Define free variables. | ||
99 | * Useful for having development builds with debug logging or adding global constants. | ||
100 | * | ||
101 | * Environment helpers | ||
102 | * | ||
103 | * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin | ||
104 | */ | ||
105 | // NOTE: when adding more properties, make sure you include them in custom-typings.d.ts | ||
106 | new DefinePlugin({ | ||
107 | 'ENV': JSON.stringify(METADATA.ENV), | ||
108 | 'HMR': METADATA.HMR, | ||
109 | 'API_URL': JSON.stringify(METADATA.API_URL), | ||
110 | 'process.version': JSON.stringify(process.version), | ||
111 | 'process.env.ENV': JSON.stringify(METADATA.ENV), | ||
112 | 'process.env.NODE_ENV': JSON.stringify(METADATA.ENV), | ||
113 | 'process.env.HMR': METADATA.HMR | ||
114 | }), | ||
115 | |||
116 | new DllBundlesPlugin({ | ||
117 | bundles: { | ||
118 | polyfills: [ | ||
119 | 'core-js', | ||
120 | { | ||
121 | name: 'zone.js', | ||
122 | path: 'zone.js/dist/zone.js' | ||
123 | }, | ||
124 | { | ||
125 | name: 'zone.js', | ||
126 | path: 'zone.js/dist/long-stack-trace-zone.js' | ||
127 | } | ||
128 | ], | ||
129 | vendor: [ | ||
130 | '@angular/platform-browser', | ||
131 | '@angular/platform-browser-dynamic', | ||
132 | '@angular/core', | ||
133 | '@angular/common', | ||
134 | '@angular/forms', | ||
135 | '@angular/http', | ||
136 | '@angular/router', | ||
137 | '@angularclass/hmr', | ||
138 | 'rxjs' | ||
139 | ] | ||
140 | }, | ||
141 | dllDir: helpers.root('dll'), | ||
142 | webpackConfig: webpackMergeDll(commonConfig({env: ENV}), { | ||
143 | devtool: 'cheap-module-source-map', | ||
144 | plugins: [] | ||
145 | }) | ||
146 | }), | ||
147 | |||
148 | /** | ||
149 | * Plugin: AddAssetHtmlPlugin | ||
150 | * Description: Adds the given JS or CSS file to the files | ||
151 | * Webpack knows about, and put it into the list of assets | ||
152 | * html-webpack-plugin injects into the generated html. | ||
153 | * | ||
154 | * See: https://github.com/SimenB/add-asset-html-webpack-plugin | ||
155 | */ | ||
156 | new AddAssetHtmlPlugin([ | ||
157 | { filepath: helpers.root(`dll/${DllBundlesPlugin.resolveFile('polyfills')}`) }, | ||
158 | { filepath: helpers.root(`dll/${DllBundlesPlugin.resolveFile('vendor')}`) } | ||
159 | ]), | ||
160 | |||
161 | /** | ||
162 | * Plugin: NamedModulesPlugin (experimental) | ||
163 | * Description: Uses file names as module name. | ||
164 | * | ||
165 | * See: https://github.com/webpack/webpack/commit/a04ffb928365b19feb75087c63f13cadfc08e1eb | ||
166 | */ | ||
167 | new NamedModulesPlugin(), | ||
168 | |||
169 | /** | ||
170 | * Plugin LoaderOptionsPlugin (experimental) | ||
171 | * | ||
172 | * See: https://gist.github.com/sokra/27b24881210b56bbaff7 | ||
173 | */ | ||
174 | new LoaderOptionsPlugin({ | ||
175 | debug: true, | ||
176 | options: { | ||
177 | |||
178 | /** | ||
179 | * Static analysis linter for TypeScript advanced options configuration | ||
180 | * Description: An extensible linter for the TypeScript language. | ||
181 | * | ||
182 | * See: https://github.com/wbuchwalter/tslint-loader | ||
183 | */ | ||
184 | tslint: { | ||
185 | emitErrors: false, | ||
186 | failOnHint: false, | ||
187 | typeCheck: true, | ||
188 | resourcePath: 'src' | ||
189 | }, | ||
190 | |||
191 | // FIXME: Remove | ||
192 | // https://github.com/bholloway/resolve-url-loader/issues/36 | ||
193 | // https://github.com/jtangelder/sass-loader/issues/289 | ||
194 | context: __dirname, | ||
195 | output: { | ||
196 | path: helpers.root('dist') | ||
197 | } | ||
198 | |||
199 | } | ||
200 | }), | ||
201 | |||
202 | new HotModuleReplacementPlugin() | ||
203 | ], | ||
204 | |||
205 | /** | ||
206 | * Webpack Development Server configuration | ||
207 | * Description: The webpack-dev-server is a little node.js Express server. | ||
208 | * The server emits information about the compilation state to the client, | ||
209 | * which reacts to those events. | ||
210 | * | ||
211 | * See: https://webpack.github.io/docs/webpack-dev-server.html | ||
212 | */ | ||
213 | devServer: { | ||
214 | port: METADATA.port, | ||
215 | host: METADATA.host, | ||
216 | historyApiFallback: true, | ||
217 | hot: METADATA.HMR, | ||
218 | watchOptions: { | ||
219 | ignored: /node_modules/ | ||
220 | } | ||
221 | }, | ||
222 | |||
223 | /* | ||
224 | * Include polyfills or mocks for various node stuff | ||
225 | * Description: Node configuration | ||
226 | * | ||
227 | * See: https://webpack.github.io/docs/configuration.html#node | ||
228 | */ | ||
229 | node: { | ||
230 | global: true, | ||
231 | crypto: 'empty', | ||
232 | fs: 'empty', | ||
233 | process: true, | ||
234 | module: false, | ||
235 | clearImmediate: false, | ||
236 | setImmediate: false | ||
237 | } | ||
238 | }), | ||
239 | |||
240 | videoEmbedConfig({env: ENV}) | ||
241 | ] | ||
242 | } | ||