Advertisement
Guest User

Untitled

a guest
May 29th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 9.59 KB | None | 0 0
  1. module.exports = {
  2.     //Exporting entry point(build data), example: const entryPoint = require('entryPoint');
  3.     externals: {
  4.         'entryPoint': tr.getEntryPoint(),
  5.         'platform': JSON.stringify(tr.getPlatform())
  6.  
  7.     },
  8.     // This makes the bundle appear split into separate modules in the devtools.
  9.     // We don't use source maps here because they can be confusing:
  10.     // https://github.com/facebookincubator/create-react-app/issues/343#issuecomment-237241875
  11.     // You may want 'cheap-module-source-map' instead if you prefer source maps.
  12.     //devtool: 'eval',
  13.     devtool:"source-map",
  14.     // These are the "entry points" to our application.
  15.     // This means they will be the "root" imports that are included in JS bundle.
  16.     // The first two entry points enable "hot" CSS and auto-refreshes for JS.
  17.     entry: [
  18.         // Include WebpackDevServer client. It connects to WebpackDevServer via
  19.         // sockets and waits for recompile notifications. When WebpackDevServer
  20.         // recompiles, it sends a message to the client by socket. If only CSS
  21.         // was changed, the app reload just the CSS. Otherwise, it will refresh.
  22.         // The "?/" bit at the end tells the client to look for the socket at
  23.         // the root path, i.e. /sockjs-node/. Otherwise visiting a client-side
  24.         // route like /todos/42 would make it wrongly request /todos/42/sockjs-node.
  25.         // The socket server is a part of WebpackDevServer which we are using.
  26.         // The /sockjs-node/ path I'm referring to is hardcoded in WebpackDevServer.
  27.         require.resolve('webpack-dev-server/client') + '?/',
  28.         // Include Webpack hot module replacement runtime. Webpack is pretty
  29.         // low-level so we need to put all the pieces together. The runtime listens
  30.         // to the events received by the client above, and applies updates (such as
  31.         // new CSS) to the running application.
  32.         require.resolve('webpack/hot/dev-server'),
  33.         // We ship a few polyfills by default.
  34.         require.resolve('./polyfills'),
  35.         // Finally, this is your app's code:
  36.         path.join(paths.appSrc, entryPoint)
  37.         // We include the app code last so that if there is a runtime error during
  38.         // initialization, it doesn't blow up the WebpackDevServer client, and
  39.         // changing JS code would still trigger a refresh.
  40.     ],
  41.     output: {
  42.         // Next line is not used in dev but WebpackDevServer crashes without it:
  43.         path: paths.appBuild,
  44.         // Add /* filename */ comments to generated require()s in the output.
  45.         pathinfo: true,
  46.         // This does not produce a real file. It's just the virtual path that is
  47.         // served by WebpackDevServer in development. This is the JS bundle
  48.         // containing code from all our entry points, and the Webpack runtime.
  49.         filename: 'static/js/bundle.js',
  50.         // In development, we always serve from the root. This makes config easier.
  51.         publicPath: '/'
  52.     },
  53.     resolve: {
  54.         // This allows you to set a fallback for where Webpack should look for modules.
  55.         // We read `NODE_PATH` environment variable in `paths.js` and pass paths here.
  56.         // We use `fallback` instead of `root` because we want `node_modules` to "win"
  57.         // if there any conflicts. This matches Node resolution mechanism.
  58.         // https://github.com/facebookincubator/create-react-app/issues/253
  59.         fallback: paths.nodePaths,
  60.  
  61.         // These are the reasonable defaults supported by the Node ecosystem.
  62.         // We also include JSX as a common component filename extension to support
  63.         // some tools, although we do not recommend using it, see:
  64.         // https://github.com/facebookincubator/create-react-app/issues/290
  65.  
  66.         extensions: ['.ts', '.tsx', '.js', '.json', '.jsx', ''],
  67.         alias: {
  68.             // Support React Native Web
  69.             // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
  70.             'react-native': 'react-native-web'
  71.         },
  72.         modules: [path.resolve('./src')]
  73.     },
  74.     // Resolve loaders (webpack plugins for CSS, images, transpilation) from the
  75.     // directory of `react-scripts` itself rather than the project directory.
  76.     // You can remove this after ejecting.
  77.     resolveLoader: {
  78.         root: paths.ownNodeModules,
  79.         moduleTemplates: ['*-loader']
  80.     },
  81.     module: {
  82.         rules: [{ test: require.resolve('jquery'), use: [{
  83.             loader: 'expose-loader',
  84.             options: {
  85.                 jQuery: true
  86.             }
  87.         }, {
  88.             loader: 'expose-loader',
  89.             options: {
  90.                 $: true
  91.             }
  92.         }] }, {
  93.             test: /\.(ts|tsx)$/,
  94.             include: paths.appSrc,
  95.             use: [{
  96.                 loader: 'ts-loader'
  97.             }],
  98.         }, // Process JS with Babel.
  99.         {
  100.             test: /\.(js|jsx)$/,
  101.             include: paths.appSrc,
  102.             use: [{
  103.                 loader: 'babel-loader'
  104.             }],
  105.             options: require('./babel.dev')
  106.         },
  107.         {
  108.             test: /\.scss$/,
  109.             use: [{
  110.                 loader: 'style-loader'
  111.             }, {
  112.                 loader: 'css-loader'
  113.             }, {
  114.                 loader: 'sass-loader'
  115.             }, {
  116.                 loader: 'postcss-loader'
  117.             }]
  118.         }, // "postcss" loader applies autoprefixer to our CSS.
  119.         // "css" loader resolves paths in CSS and adds assets as dependencies.
  120.         // "style" loader turns CSS into JS modules that inject <style> tags.
  121.         // In production, we use a plugin to extract that CSS to a file, but
  122.         // in development "style" loader enables hot editing of CSS.
  123.         {
  124.             test: /\.css$/,
  125.             use: [{
  126.                 loader: 'style-loader'
  127.             }, {
  128.                 loader: 'css-loader'
  129.             }, {
  130.                 loader: 'postcss-loader'
  131.             }]
  132.         }, // "file" loader makes sure those assets get served by WebpackDevServer.
  133.         // When you `import` an asset, you get its (virtual) filename.
  134.         // In production, they would get copied to the `build` folder.
  135.         {
  136.             test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
  137.             exclude: /\/favicon.ico$/,
  138.             use: [{
  139.                 loader: 'file-loader'
  140.             }],
  141.             options: {
  142.                 name: 'static/media/[name].[hash:8].[ext]'
  143.             }
  144.         }, // A special case for favicon.ico to place it into build root directory.
  145.         {
  146.             test: /\/favicon.ico$/,
  147.             include: [paths.appSrc],
  148.             use: [{
  149.                 loader: 'file-loader'
  150.             }],
  151.             options: {
  152.                 name: 'favicon.ico?[hash:8]'
  153.             }
  154.         }, // "url" loader works just like "file" loader but it also embeds
  155.         // assets smaller than specified size as data URLs to avoid requests.
  156.         {
  157.             test: /\.(mp4|webm)(\?.*)?$/,
  158.             use: [{
  159.                 loader: 'url-loader'
  160.             }],
  161.             options: {
  162.                 limit: 10000,
  163.                 name: 'static/media/[name].[hash:8].[ext]'
  164.             }
  165.         }, // "html" loader is used to process template page (index.html) to resolve
  166.         // resources linked with <link href="./relative/path"> HTML tags.
  167.         {
  168.             test: /\.html$/,
  169.             use: [{
  170.                 loader: 'html-loader'
  171.             }],
  172.             options: {
  173.                 attrs: ['link:href'],
  174.             }
  175.         }]
  176.     },
  177.  
  178.     // Include & resolve this path for scss files ***-CONF
  179.     sassLoader: {
  180.         includePaths: [path.resolve("./src/assets/scss")]
  181.     },
  182.  
  183.     // Point ESLint to our predefined config.
  184.     eslint: {
  185.         configFile: path.join(__dirname, 'eslint.js'),
  186.         useEslintrc: false
  187.     },
  188.     // We use PostCSS for autoprefixing only.
  189.     /*postcss: function() {
  190.         return [
  191.             autoprefixer({
  192.                 browsers: [
  193.                     '>1%',
  194.                     'last 4 versions',
  195.                     'Firefox ESR',
  196.                     'not ie < 9', // React doesn't support IE8 anyway
  197.                 ]
  198.             }),
  199.         ];
  200.     },*/
  201.     plugins: [
  202.         //new I18nPlugin(languages,{functionName:"T.t"}),
  203.         // Generates an `index.html` file with the <script> injected.
  204.         new HtmlWebpackPlugin({
  205.             inject: true,
  206.             template: paths.appHtml,
  207.         }),
  208.         // Makes some environment variables available to the JS code, for example:
  209.         // if (process.env.NODE_ENV === 'development') { ... }. See `env.js`.
  210.         // new webpack.DefinePlugin(env),
  211.         // This is necessary to emit hot updates (currently CSS only):
  212.         new webpack.HotModuleReplacementPlugin(),
  213.         // Watcher doesn't work well if you mistype casing in a path so we use
  214.         // a plugin that prints an error when you attempt to do this.
  215.         // See https://github.com/facebookincubator/create-react-app/issues/240
  216.         new CaseSensitivePathsPlugin(),
  217.         // If you require a missing module and then `npm install` it, you still have
  218.         // to restart the development server for Webpack to discover it. This plugin
  219.         // makes the discovery automatic so you don't have to restart.
  220.         // See https://github.com/facebookincubator/create-react-app/issues/186
  221.         new WatchMissingNodeModulesPlugin(paths.appNodeModules),
  222.         new AssetsPlugin({
  223.             prettyPrint: true,
  224.             filename: 'generated-assets.json'
  225.         })
  226.  
  227.     ]
  228. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement